Delete-sized

Discuss and share scripts and script files...
Post Reply
bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Delete-sized

Post by bdeshi »

This when triggered displays total (recursive) size of selected items and prompts to delete them. I've been using it very often, so sharing sounded like a good idea.
I've since made some small changes since it's birth here

I should first post a
WARNING: Read what each button does in the delete prompt before clicking!
Yes: Delete permanently, No: Send to Recycler, Cancel: Cancel delete operation.



deletesized.xys
SCRIPT:

Code: Select all

  //delete items, showing total size

  /*v Settings*/
    $BG = 1; //1: delete in background, 2: in foreground, else current setting
  /*^ Settings*/
  $focus = get('FocusedControl');
  $items = ($focus == 'T')  ? (<curpath>) :
           (($focus == 'L') ? get('SelectedItemsPathNames', '|') : ('')) ;
  end ($items == ''),, 1; unset $focus;
  $grandsize = 0; $size = 0;
  foreach ($item, $items, '|') {
   $size      = (exists($item) != 1) ? foldersize($item, '<r>', 1) : filesize($item) ;
   $grandsize = $grandsize + $size;
   status     "calculating size: " . $grandsize,, 'progress'; wait 1;
  }
  $grandsize = formatbytes($grandsize, 'FLEX');
  $ques      = "You're about to delete $grandsize in total<crlf 2>".
               "Yes: Delete PERMANENTLY, No: Send to RECYCLER, Cancel: Abort<crlf>";
  $decision  = confirm($ques,, 3/*focus 'Cancel'*/, 3/**btns:Yes/No/Cancel*/);

  if ($BG == 1){setting 'backgroundFileOps', 1; setting "backgroundedFileOps", 16;}
  elseif ($BG == 2){setting 'backgroundFileOps', 0; }

  if     ($decision == 0){ delete 1, 0, $items; } //No:  delete to RECYCLER
  elseif ($decision == 1){ delete 0, 0, $items; } //Yes: Delete PERMANENTLY


SETUP:
I find it works best when used with/as a delete shortcut. So let's assign it a UDC.
Save the script to <xyscripts>\udc\deletesized.xys
Now create a "Load Script" UDC (Menu > User > Manage Commands > select Load Script File > press INSERT):

Code: Select all

caption    : Delete (Show Size)
scriptfile : udc\deletesized.xys
label      : 
check "on KeyUp", and copy the caption text you've used.
Open Tools > Customize Keyboard shortcuts > press Jump and paste the caption text.
Double-click on the relevant result, (prepended with User | Load Script File | ), and then assign your desired keyboard shortcut.

(I've set it up with CTRL+DEL)
To see the attached files, you need to log into the forum.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Post Reply