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");
}
}