wait inside foreach loop , how ?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
bossi
Posts: 144
Joined: 30 Jul 2022 11:09
Location: Win11-latest, XYx64 latest, 4K@100%

wait inside foreach loop , how ?

Post by bossi »

Hi frens ,

in a scenario, where multiple files are selected , and each is compressed into its own <basename>.7z archive,
how to make "while-exists-wait" work correctly ?
When the compression is done , 7zip deleted the compressed item , so the loop should go to the next item.
Currently the Script triggers all selected items at once , not one by one.

Code: Select all

foreach($path,$paths){
	$name = gpc($path, "name",,4);
	$archive_name = $name . ".7z";
 	run lax($zip7g a -mx5 -md96m "$archive_name" "$path" -sdel);} //7zip  compression starts, deletes selected afterwards
	while (exists($path) >= 1 )                                           // while $path exists , wait , then continue
		{wait 250;}
However, it works correctly in a scenario, where the selected items are folders , and each loop starts with a "goto folder" command.

Code: Select all

foreach($path,$paths){
	goto "$path";
	select all;
	compress;
	while (exists($path) >= 1 ) 
		{wait 250;}

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

Re: wait inside foreach loop , how ?

Post by highend »

setting "BackgroundFileOps", 0;

before the loop and there is no need to test for existence of the path...
One of my scripts helped you out? Please donate via Paypal

bossi
Posts: 144
Joined: 30 Jul 2022 11:09
Location: Win11-latest, XYx64 latest, 4K@100%

Re: wait inside foreach loop , how ?

Post by bossi »

THX !!! understood the setting now :biggrin:

Post Reply