Page 1 of 1

Scripting - run dos commands without blocking xyplorer?

Posted: 26 Jun 2011 20:13
by highend
Hi,

I created a little script that should convert my audio files (multiple selected) to mp3 (192kbit CBR) via Sox.

What I'd like to achieve is: Take the first selected audio file, convert it; take the second one, convert it, etc.
Step by step.
What I don't want: Block XYplorer while the files are converted / the script is running.

Using "run" with wait=1 instead of "open" isn't an option, XYplorer will not be accessible as long as the script is running and if I use open it will take all selected files at once and creates a dos window for each (and I want to avoid that^^).

Any hints?

Code: Select all

// 26.06.2011, use sox to convert to .mp3
	// Declare variables
	$sox_cmd = "<xydrive>\Tools\Sox_CLI\sox.exe";
	$items = get("SelectedItemsPathNames", "|");

	if ($items>"")
	{
		$loop = 1;
		$count = 0;
		$array = "";
		while(true)
		{
			$entries = gettoken($items, $loop, "|");
			if ($entries == "") {break;}
			$cur_array_element = $entries;
			incr $count;
			$input_ext = substr("$cur_array_element", -4);
			$outputfile = replace("$cur_array_element", "$input_ext", "");
			$outputfile = $outputfile . "_192.mp3";
			open """$sox_cmd"" -S --multi-threaded ""$cur_array_element"" -C 192.2 ""$outputfile"" rate -v 44100";
			incr $loop;
		}
	}
Regards,
highend

Re: Scripting - run dos commands without blocking xyplorer?

Posted: 26 Jun 2011 20:24
by nas8e9
I'd have a script create a batch file with each item on a separate line. By having the script end with

Code: Select all

run '"%Temp%\ConvertTemp.cmd"', wait=0
the batch file will be started and the script will continue/end, thus making XYplorer available again.

Re: Scripting - run dos commands without blocking xyplorer?

Posted: 28 Jun 2011 12:07
by highend
Thanks nas8e9,

seems to be the only possible solution atm.

Script changed (writes a .bat file and executes it afterwards), working fine now.