Multi-combo of script(s) and UDC(s)

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Multi-combo of script(s) and UDC(s)

Post by ivan »

Hello,

I was wondering if there is a way to combine script(s) and UDC(s) into one action?

With a folder's view in right-hand pane (no files are selected) one touch of a button will do this:

1. Find and extract any RAR file in the core folder (the one that's being viewed)

This is already partially handled via this UDC

http://www.xyplorer.com/xyfc/viewtopic.php?t=2386

2. Rename the resulting file (there is always just one) to the name of the folder

This is handled by this script

http://www.xyplorer.com/xyfc/viewtopic.php?t=2338

3. Move this newly-renamed file into the folder that's one level higher in the tree structure

4. Delete the folder (and any subfolders) from which the file has been moved.

I know it's tricky and I'm probably asking for too much but with introduction of scripting and XYplorer's motto being "simplifying the tedious tasks", a challenge like this should be a good one to thrive on. Should I hold my breath or is it the case of "no way, Jose"? Thanks a lot 8)

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

Re: Multi-combo of script(s) and UDC(s)

Post by admin »

ivan wrote:I was wondering if there is a way to combine script(s) and UDC(s) into one action?
I did not even read the rest of your post because the answer is easy: yes, of course! Each UDC has a unique function ID so you can reference it within a script.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Post by serendipity »

After you have finished 1. and 2. with the scripts you have i guess you will end up with your one file in the list (which i guess is selected).

Then follow this script:

Code: Select all

//move file one level higher
 moveto ..\, <curitem>;
// Go one level higher
 #523;
// Delete the folder
 #169

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

Thanks, is there a way to do it (all 4 steps) without me having to manually select a file? If there is not then steps 1 and 2 will have to be done separately and me manually selecting the file each time.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Post by serendipity »

But i guess after 1. and 2. your file should be selected. But if your file is still in rename mode then add "focus;" and it should escape rename mode and should be selected.

//focus list
focus;
//move file one level higher
moveto ..\, <curitem>;
// Go one level higher
#523;
// Delete the folder
#169

RalphM
Posts: 2089
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Multi-combo of script(s) and UDC(s)

Post by RalphM »

@serendipity: I guess you didn't read that part of ivan's post thoroughly...
ivan wrote:With a folder's view in right-hand pane (no files are selected) one touch of a button will do this:

1. Find and extract any RAR file in the core folder (the one that's being viewed)
I guess, if there's only one RAR in the folder you could either filter your list for it or do a find first and then select that file, from there follow the steps provided by serendipity.
To handle more than one RAR in a folder would need loop commands in scripting, which will come in scripting 2.0.

...no wait, since you delete the RAR files anyway after extracting you could actually just repeat the find after you processed one file, until there are no more RAR's in the folder...

I rather leave the technical part to serendipity who's (one of) our scripting experts.

If nobody comes up with a solution, I might give it a try, but not right now.
Ralph :)
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Post by serendipity »

OK, Let me understand this with an example:

1. You have a RAR file "XYZ.RAR" inside the folder "ABC". So, lets say the folder structure looks like C:\ABC\XYZ.RAR.
2. And say the XYZ.RAR contains file PQR.jpeg.
3. You want to extract PQR.jpeg into ABC.
4. Rename PQR.jpeg to ABC.jpeg.
5. Move ABC.jpeg into C:\.
6. Delete ABC.

Is that example right?

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

serendipity wrote:OK, Let me understand this with an example:

1. You have a RAR file "XYZ.RAR" inside the folder "ABC". So, lets say the folder structure looks like C:\ABC\XYZ.RAR.
2. And say the XYZ.RAR contains file PQR.jpeg.
3. You want to extract PQR.jpeg into ABC.
4. Rename PQR.jpeg to ABC.jpeg.
5. Move ABC.jpeg into C:\.
6. Delete ABC.

Is that example right?
That's perfectly correct, except most of the time there will be a sequence of RARs instead of just one. Not sure if that complicates things or not though... :?

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

ivan wrote:That's perfectly correct, except most of the time there will be a sequence of RARs instead of just one. Not sure if that complicates things or not though... :?
hmm.. and by any chance, wouldn't all the extracted files always be of the same group of extensions ?

Cause then I'm guessing this should do it (of course you need to replace *.ext1|*.ext2 by the actual extension of the files you extract/wanna keep)

Code: Select all

	setting "HideFoldersInList", 0;
	focus l;
	sortby name,a;
	sel 1,0;
	sel "[*.rar]";
	openwith """WinRAR"" x -- <items>";
	filter "!*.ext1|*.ext2";
	sel a;
	// Delete
	#170;
	filter;
	sel a;
	rename , <curfolder>;
	moveto "..";
	// Up
	#523;
	// Delete
	#170;
Of course you should try this on some test files/folders at first, maybe with Stepping enabled, cause I haven't tried it myself so you're never too careful.
But it should select the first *.rar file on the folder, and start the extraction (using WinRAR, must be installed/registered app). Then it will filter out the files you wanna keep (are extracting), selects everything (else) and go to delete it all.

Obviously, this can only works if you do NOT have "Turn off delete confirmation", because you need that confirmation and you need to wait until WinRAR is done extracting everything before click "Yes" to the delete confirmation, otherwise you'll loose everything.

Once the extraction is succesful, you say "Yes" and all the files (that haven't been filtered out) will be deleted, then we remove the filter, selects everything (so the files extracted), rename them to the current folder and move them one level. Then we go there and remove the folder (since going up it should be selected automatically).

Again, make sure to use copies of files in some test folders cause I haven't tried it myself.
Proud XYplorer Fanatic

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

First of all, thank you for this. Second of all, here's a bit of feedback. In short, it didn't work. I'll just describe the series of events and you'll tell me what's ok and what's not.

I pressed the button assigned to this script and straight way it started extracting, but also removed all the files in this folder and XYplorer popped up with a message saying "Nothing to delete". After extraction, it moved all the files (from where though?) into the folder one step up a tree, renamed the extracted file into the name of the dir where it initially was extracted and then went ahead and renamed all the RAR archives into the name of the dir as well.

To sum up, everything worked except the error message saying "Nothing to delete" popped up, RAR archives were also transferred up the tree, RAR archives were renamed into the directory's name from which they were transferred.

I have ext1 set as rar and ext2 set as avi. Where do we go from here? :)

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

hmm.. okay so if I get things right, when you say "removed all the files in this folder" I think that they "disappeared" from the List because of the VF (they were hidden, filtered out, but not deleted), hence why they could be moved/renamed afterwards.

Question : do yo want to keep the RAR files when done, or not ? I was under the impression you didn't want to, but only keep the extracted files. If that is the case, you shouldn't put *.rar as files to keep.

If you remove it, then instead of "Nothing to delete" you should get a confirmation to delete all the selected (RAR) files. Saying yes once the extraction is complete should then do what you want, I think.
Proud XYplorer Fanatic

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

No, I don't want to keep the RAR files but I am puzzled why they got moved up the tree and also renamed. I don't mind clicking on a message asking me if I want to delete (though I'd rather that message didn't pop up) but it's the moving of the RARs up the tree and renaming them that puzzles me.

P.S. It also turns out that when asked to delete by XYplorer it really did mean delete and not "Place in Recycle Bin". I'd rather it moved stuff to the bin first so then I can empty it at my convenience.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

ivan wrote:No, I don't want to keep the RAR files but I am puzzled why they got moved up the tree and also renamed.
Cause what the script does is rename & move all files in the folder (after deletion), and the RAR files hadn't been deleted, so they got renamed & moved as well. But if you don't include *.rar and only *.avi they will then not be renamed or moved, but deleted.
ivan wrote:I don't mind clicking on a message asking me if I want to delete (though I'd rather that message didn't pop up)
That confirmation is actually helpful, it allows you to wait for the extraction to complete, and only then let XY delete the files and moves on (rename files, move them up, etc) ;)
ivan wrote:P.S. It also turns out that when asked to delete by XYplorer it really did mean delete and not "Place in Recycle Bin".
Oh, right... just replace #170; by #169; and it'll use the Recycle Bin!
Proud XYplorer Fanatic

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

Made those changes but now, after deleting the RARs and renaming into what the dir's name is, XYplorer comes up with a message saying that the destination folder is the same as the source folder. I click Cancel and now it asks me if i want to put directory A (RARs were in A --> B) in Recycle Bin. Of course I clicked No, because it needs to delete B and not A. We'll get there eventually, thanks again for the help :)

So it did extract, renamed the file and deleted the RARs, but it did not move the AVI up the tree and it tried to delete the wrong folder.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

ivan wrote:Made those changes but now, after deleting the RARs and renaming into what the dir's name is, XYplorer comes up with a message saying that the destination folder is the same as the source folder. I click Cancel and now it asks me if i want to put directory A (RARs were in A --> B) in Recycle Bin. Of course I clicked No, because it needs to delete B and not A. We'll get there eventually, thanks again for the help :)

So it did extract, renamed the file and deleted the RARs, but it did not move the AVI up the tree and it tried to delete the wrong folder.
hmm.. well I'm not sure what's going on then. I just tried it, put in a folder a RAR then started the script, once the extraction was over I clicked "Yes" to delete the RAR, and ended up one level up being asked to remove the (now empty) folder I was just in, with the extracted file sitting here renamed to the folder I was about to delete.
In other words, it worked perfectly!

I can't think of a reason why you'd get such an error, "destination folder is the same as the source folder", since the destination is ".." hence the parent, so I don't see how it could possibly be the same. Unless maybe on a root, but since you're on a folder (the one that originally contains the RARs) I don't know :?
Proud XYplorer Fanatic

Post Reply