Using the UDC (User-Defined Commands), I've created a simple script from commands and assigned an keyboard shortcut (ALT+6 in my case):
________________________________________________
#254;#252;#169;#642
(Select by file type / invert selection / delete files / empty recycle bin)
________________________________________________
I use this to delete PAR2 and RAR files after downloading from a newsgroup.
Script for deleting all files except by selected file type
Re: Script for deleting all files except by selected file ty
Hi there, I'm very new to XYplorer and I understand only very basic scripting. I'm using the latest version of XYplorer and I have tried this script, which might a bit old for my version and may be the reason it isn't working properly. When I run this script I get a message window saying "Nothing to delete". I have tried starting with just the first command adding the rest one at a time. The "select all by filetype" works fine - it still works when I add "invert selection" - but as soon as I add "delete" I get the message window. I've tried creating another script with just the delete command (and all the other possible delete options) but the same thing happens. I'm running Windows 7 Home Premium 64-bit. Cheers from De (making my first post).
zridling wrote:Using the UDC (User-Defined Commands), I've created a simple script from commands and assigned an keyboard shortcut (ALT+6 in my case):
________________________________________________
#254;#252;#169;#642
(Select by file type / invert selection / delete files / empty recycle bin)
________________________________________________
I use this to delete PAR2 and RAR files after downloading from a newsgroup.
Windows 10 Pro 22H2
Re: Script for deleting all files except by selected file ty
Give this a try:
The problem you're seeing is that #169 "File | Delete" works on the selected item(s) in the focused control.
So depending on how you call the script focus might not be in the list pane, and in fact if you weren't so lucky focus could be in the Tree pane causing it to delete the selected folder.
Another solution would be to force it to focus the list within the script:
Personally, I avoid using command IDs (#252;) when scripting commands (Sel 'i';) are available since it tends to make things easier to understand later.
Code: Select all
"Delete All but Selected Type(s)"
#254; // Edit | Select | Select By Selected Type(s)
Sel 'i'; // Invert Selection
Delete(0 /*Skip Recycle Bin*/, 1 /*Confirm*/, ':list');
So depending on how you call the script focus might not be in the list pane, and in fact if you weren't so lucky focus could be in the Tree pane causing it to delete the selected folder.
Another solution would be to force it to focus the list within the script:
Code: Select all
#1016;#254;#252;#169;#642;
//or using the scripting command:
Focus('List');#254;#252;#169;#642;
//(Focus List / Select by file type / invert selection / delete files / empty recycle bin)
Re: Script for deleting all files except by selected file ty
Hey thanks TheQwerty, I barely understood a thing you said now, let alone worrying understanding things later LOL! But I can tell you this works:
This doesn't - it invokes the same "Nothing to delete" message as before:
This works too:
...although I didn't want the 'empty recycle bin' part so I deleted that.
Cheers from De.
Code: Select all
"Delete All but Selected Type(s)"
#254; // Edit | Select | Select By Selected Type(s)
Sel 'i'; // Invert Selection
Delete(0 /*Skip Recycle Bin*/, 1 /*Confirm*/, ':list');
Code: Select all
#1016;#254;#252;#169;#642;
Code: Select all
Focus('List');#254;#252;#169;#642;
Cheers from De.
Windows 10 Pro 22H2