Actually, I've found so many solutions to this question, but none works. The program I'd like to run in Powershell is Reaper - a Digital Audio Workstation, and I'm going to use its command line tool for batch-processing audio files within a PS script. The code related to Reaper is as below:
reaper -batchconvert $output_path\audio\Reaper_filelist.txt
I'm going to use the Start-Process
with -wait
parameter to allow my script to wait for it to end then go on to the next line of code which is a Rename-Item
function.
ls $processed_audio_path | Rename-Item -NewName {$_.name.Replace("- ", "")}
If PS doesn't wait for the process to finish, then the next line would throw an error, something like "no such file was found in the directory".
The suggestions I've found are here, here, and here. But none of those work. The problem is that Reaper doesn't accept the argument to be added separately as:
$exe = "reaper"
$arguments = "-batchconvert $output_path\audio\Reaper_filelist.txt"
Start-Process -filepath $exe -argumentlist $arguments -wait
or:
Start-Process -filepath reaper -argumentlist "-batchconvert $output_path\audio\Reaper_filelist.txt" -Wait
or:
Start-Process -filepath reaper -argumentlist @("-batchconvert", "$output_path\audio\Reaper_filelist.txt") -Wait
It can only work without a problem as a whole block like the first code line above. So what can I do now?