Extract and rename extracted files

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
kiwichick
Posts: 648
Joined: 08 Aug 2012 04:14
Location: Windows 10 Pro 22H2, 150% scaling

Extract and rename extracted files

Post by kiwichick »

I often download zip files containing images files that need to be renamed after extracting. I have two scripts. One that does the extracting and one that does the renaming. I'd like to combine them into the one process but I'm not having any luck. The issue I have is how to make sure the renaming portion of the script doesn't begin until the extraction has completed and the files appear in the list. I've tried using the Wait command but, because the amount of time it takes to extract depends upon how many files there are (and their combined size), it's not very successful. If I use too short a time, I get an error if the script tries to rename before extraction hasn't finished, or before the files appear in the list. If I use too long a time, there's unnecessary waiting for short extractions.

Here are my two scripts:

Code: Select all

end(getinfo("CountSelected") < 1), "Nothing selected!";
 zip_extract("", "",,,1);

Code: Select all

focus "L"; 
selectitems "*.png|*.jpg";

rename r, "(.+) - S(.+) > s$2";
rename s, " /";
rename r, "(.+) \[(.+)\].*$ > $1.jpg";
rename r, "(.+)\[(.+)\].*$ > $1.jpg";

$season = "season*";
$specials = "specials";
foreach($item, <get SelectedItemsNames>, <crlf>, "e") {
  $base = gpc($item, "base");
  $ext = gpc($item, "ext");
  if($base UnLikeI $season && $base UnLikeI $specials){
	RenameItem("poster.$ext", "$item");
	}
  if($base LikeI "season0"){
	RenameItem("specials.$ext", "$item");
	}
  }
Windows 10 Pro 22H2

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Extract and rename extracted files

Post by highend »

Then don't do this with visible files but scan for them (the script doesn't continue anyway as long as the extraction isn't finished yet) (listfolder() / quicksearch()) and then do all renaming stuff on what's inside the variable instead of any selection first...
One of my scripts helped you out? Please donate via Paypal

kiwichick
Posts: 648
Joined: 08 Aug 2012 04:14
Location: Windows 10 Pro 22H2, 150% scaling

Re: Extract and rename extracted files

Post by kiwichick »

highend wrote: 20 May 2024 05:08 Then don't do this with visible files but scan for them (the script doesn't continue anyway as long as the extraction isn't finished yet) (listfolder() / quicksearch()) and then do all renaming stuff on what's inside the variable instead of any selection first...
Thanks, highend, but I don't understand what you're suggesting.
Windows 10 Pro 22H2

jupe
Posts: 3292
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Extract and rename extracted files

Post by jupe »

You probably just need a refreshlist; after the zip_extract though if you didn't want to rewrite the whole thing.

kiwichick
Posts: 648
Joined: 08 Aug 2012 04:14
Location: Windows 10 Pro 22H2, 150% scaling

Re: Extract and rename extracted files

Post by kiwichick »

jupe wrote: 20 May 2024 05:18 You probably just need a refreshlist; after the zip_extract though if you didn't want to rewrite the whole thing.
Thank you!! Perfect.
Windows 10 Pro 22H2

Post Reply