mhmsa
mhmsa

Reputation: 475

Batch For /r Start program acting up

I am trying to make a very simple script to locate wav files in multiple subfolders and use the names of the wave files as arguments to a small program that i've copied into each of the subfolders i tried different variations of calling the program and passing the arguments to it,that's my latest version

 FOR /R F:\database\Testing %%G IN (*.wav) DO start /wait /separate %%~dpGproc_eng_track.exe %%~dpnG

I get an error saying something like Cannot find the directory containing proc_eng_track component which is required by this application. Make sure the directory containing proc_eng_track is in the path

The thing is the script was running fine on another pc here is the exact script that was working on other pc

FOR /R C:\database\CAP\Session1\sentences\wav %%G IN (*.wav) DO start "" /wait /separate %%~pG/proc_eng_track.exe %%~pnG

the program runs fine if i go into each subfolder and do a forfiles loop but that's exhausting considering the number of files any hints would be great

Upvotes: 0

Views: 65

Answers (2)

foxidrive
foxidrive

Reputation: 41234

This enters each folder and runs the local exe with the file. See if the EXE file behaves for you this way:

@echo off
FOR /R "F:\database\Testing" %%G IN (*.wav) DO (
pushd "%%~dpG"
start "" /wait /separate "proc_eng_track.exe" "%%~dpnG"
popd
)

By rights this should work with a single copy of the EXE file, assuming the exe file knows where any support files it may have are located:

@echo off
FOR /R "F:\database\Testing" %%G IN (*.wav) DO (
 pushd "%%~dpG"
   start "" /wait /separate "c:\program folder\proc_eng_track.exe" "%%~dpnG"
 popd
)

Upvotes: 1

tremor
tremor

Reputation: 3186

Instead of copying your program into each folder, why not setup your system PATH variable to the programs main directory? This can be done on many ways on various versions of windows, there is plenty of literature available via a simple Google Search "setup PATH on windows (whatever version)".

This way, you just call the .exe because it is "globally" known and the error" Cannot find the directory containing proc_eng_track component" will go away because you obviously need more than just the single exe to run whatever program you are running.

Upvotes: 0

Related Questions