Possible to show size when deleteing

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
fogg
Posts: 32
Joined: 15 Jul 2014 16:13
Location: Going around the World

Possible to show size when deleteing

Post by fogg »

Hello,
I want to know total size of files when deleting something. Is it possible? I think XYplorer is able to do this, but I didn't find any option. :(
s404:signature not found.

admin
Site Admin
Posts: 66297
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Possible to show size when deleteing

Post by admin »

Edit | Select | Selection Stats?

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Possible to show size when deleteing

Post by bdeshi »

Try this. You'll get a confirmation before the actual delete confirmation. Safety belt.

Code: Select all

 $focus = get('FocusedControl');
 $items = ($focus == 'T') ? <curpath> : ( ($focus == 'L') ? get('SelectedItemsPathNames', '|') : '' ) ;
 end ($items == '');
 unset $focus;
 $grandsize = 0; $size = 0;
 foreach ($item, $items, '|'){
  $size      = (exists($item) != 1) ? foldersize($item, '<r>', 1) : filesize($item) ;
  $grandsize = $grandsize + $size;
 }
 $grandsize = formatbytes($grandsize, 'FLEX');
 $ques      = "You're about to delete $grandsize in total.<crlf 2>Continue?";
 if (confirm($ques,,,4/**btns:Yes/No*/) == 1){ #169 ;/*File > Delete*/ }
This will display total size of all selected files and folders before deleting, so sometimes the calculation might take sometime. (Although in my short tests the performance was surprisingly fast! :shock: )

Now You know there are different shortcuts for different types of deletions? (delete skip locked, delete without recycling,...) Well, how about making this behave like another extra mode? Just assign it a shortcut with delete button! Here's how.
  • Open Main Menu > User > Manage commands
  • pick the "Run script" category.
  • Click New > add new command (or just press INSERT key) .
  • Enter "Delete (show total size)" in the "Caption" box. Or enter whatever you want to call it.
  • Press the EDIT button beside "Script" box. In the opened textbox, paste the whole script above. (make sure the spaces are there before each line)
  • "OK" out out of there.
  • Now set up a hotkey with "Assign keyboard shortcut" button. Press that button, then press DELETE key to jump to free shortcuts with DELETE.
    I suggest you also check "On keyup"
Alright! Now you can do DELETE: regular delete prompt, SHIFT+DELETE: delete (no recycling), CTRL+DELETE: Delete (skip locked items), CTRL+SHIFT+DELETE: delete (no recycling, skip locked), and [CTRL+] SHIFT+ALT+DELETE: delete (show total size) !
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

fogg
Posts: 32
Joined: 15 Jul 2014 16:13
Location: Going around the World

Re: Possible to show size when deleteing

Post by fogg »

admin wrote:Edit | Select | Selection Stats?
Thanks, but That is not quick, I need to use that menu, then again do delete.
s404:signature not found.

admin
Site Admin
Posts: 66297
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Possible to show size when deleteing

Post by admin »


fogg
Posts: 32
Joined: 15 Jul 2014 16:13
Location: Going around the World

Re: Possible to show size when deleteing

Post by fogg »

:appl: :appl: :appl: :appl: Thank you very much SammaySarkar! This is exactly what I needed!
I use the Ctrl+Del for this script because I don't use Delete (Skip Locked) #171
But can it delete with only one confirmation?

Again Many thanks,
Phil
s404:signature not found.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Possible to show size when deleteing

Post by bdeshi »

My pleasure. :)
fogg wrote:But can it delete with only one confirmation?
Sure. Replace the very last line,

Code: Select all

 if (confirm($ques,,,4/**btns:Yes/No*/) == 1){ #169 ;/*File > Delete*/ }
with this:

Code: Select all

 if (confirm($ques,,,4/**btns:Yes/No*/) == 1){ delete 1, 0, $items; }
Again make sure there's (at least) one space at the beginning of the line.

This will delete selected items to recycle bin. Replace the 1 after "delete" to 0 to delete permanently; I don't suggest that though.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

fogg
Posts: 32
Joined: 15 Jul 2014 16:13
Location: Going around the World

Re: Possible to show size when deleteing

Post by fogg »

It's perfect now! :appl: :appl: Wioderful!
s404:signature not found.

fogg
Posts: 32
Joined: 15 Jul 2014 16:13
Location: Going around the World

Re: Possible to show size when deleteing

Post by fogg »

Hello again.
I have a problem. nothing happens When I press control + delete to open this script. Next time, it opens a message box saying

Code: Select all

a user-defiend command (#1403) is not allowed to call itself
:?: :?: :?:
s404:signature not found.

fogg
Posts: 32
Joined: 15 Jul 2014 16:13
Location: Going around the World

Re: Possible to show size when deleteing

Post by fogg »

more: also short time later opens a script error box as

Code: Select all

Access is denied
s404:signature not found.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Possible to show size when deleteing

Post by bdeshi »

fogg wrote:Hello again.
I have a problem. nothing happens When I press control + delete to open this script. Next time, it opens a message box saying

Code: Select all

a user-defined command (#1403) is not allowed to call itself
:?: :?: :?:
This is because you'd selected a really huge folder and XY needed some time to calculate the total size. But you called the script again meanwhile, without letting the previous instance finish it's calculation.
So if this happens again, remember that the script hasn't died fighting an error but just needs more time.
Also remember, to stop calculation at any time, press ESC (twice). :wink:
fogg wrote:more: also short time later opens a script error box as

Code: Select all

Access is denied
You selected something that XY cannot delete. Say maybe a hard disk Drive root, C:\, D:\ ... ? (that's where I got the same result) Y'know, In this case even for usual deletion XY displays an alert, which is not much less alarming than an scripting error. :x

Hmm, the script better not calculate at all when drives are selected, but another solution is: just don't trigger it on whole drives! :kidding:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

PeterH
Posts: 2827
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Possible to show size when deleteing

Post by PeterH »

@Sammay: show per Status cmd that script is working, and then when it's finished?
(Use Color to clearly show progress state.)

This at least gives some hint to the user.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Possible to show size when deleteing

Post by bdeshi »

I tried it, but since size of each selected folder/file is calculated in a single statement, status update will still seem to freeze/stutter if that folder happens to be large.

Anyways, here's that script with periodic updates:

Code: Select all

 $focus = get('FocusedControl');
 $items = ($focus == 'T') ? <curpath> : ( ($focus == 'L') ? get('SelectedItemsPathNames', '|') : '' ) ;
 end ($items == '');
 unset $focus;
 $grandsize = 0; $size = 0;
 foreach ($item, $items, '|'){
  $size      = (exists($item) != 1) ? foldersize($item, '<r>', 1) : filesize($item) ;
  $grandsize = $grandsize + $size;
  status "calculated size: " . $grandsize ,, 'progress';
 }
 $grandsize = formatbytes($grandsize, 'FLEX');
 $ques      = "You're about to delete $grandsize in total.<crlf 2>Continue?";
 if (confirm($ques,,,4/*btns:Yes/No*/) == 1){ #169 ;/*File > Delete*/ }
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

eil
Posts: 1866
Joined: 13 Jan 2011 19:44

Re: Possible to show size when deleteing

Post by eil »

SammaySarkar, can you please modify script with extra safety to check if Delete is happening on non-hard drives and taking it to user's notice?
like having a variable with list of hard-drive letters user has, and if any is present in pathes, add extra line to that Question-dialog, stating that "Delete on < G > drive, will be permanent!"
Win 7 SP1 x64 100% 1366x768|1900x1080

eil
Posts: 1866
Joined: 13 Jan 2011 19:44

Re: Possible to show size when deleteing

Post by eil »

modified script myself, maybe someone will find it useful too(just use your hard-drive letters). i'd only wish i could "use bbcode" to mark some words with bold or underline.. :cry:
now shows size, number of items, drive letter and additional warning if it's not stated drives.

Code: Select all

 $focus = get('FocusedControl');
 $items = ($focus == 'T') ? <curpath> : ( ($focus == 'L') ? get('SelectedItemsPathNames', '|') : '' ) ;
 end ($items == '');
 $drive = substr("<curpath>", , 1); //check for letter
 if ($drive == "C" || $drive == "D" || $drive == "E" || $drive == "F") {$warning = ''} else {$warning = "This will be PERMANENT!<crlf>"};
 unset $focus;
 $grandsize = 0; $size = 0; $num = 0;
 foreach ($item, $items, '|'){
  $size      = (exists($item) != 1) ? foldersize($item, '<r>', 1) : filesize($item) ;
  $grandsize = $grandsize + $size;
  $num++;
  status "calculated size: " . $grandsize ,, 'progress'; }
 $grandsize = formatbytes($grandsize, 'FLEX');
 $ques = "You're about to delete $num items <crlf>$grandsize from = $drive:\ <crlf 2>$warning  Continue?";
 if ($warning != '') {beep 2000, 50; beep 2000, 50;};
 if (confirm($ques,,,4/**btns:Yes/No*/) == 1){ delete 1, 0, $items; } //to Recycle
Win 7 SP1 x64 100% 1366x768|1900x1080

Post Reply