Rick
Rick

Reputation: 11

bat file to run perl script on all sub directories

I have a simple bat file that sets a directory and runs a perl on the directory.

cd Q:\Research\Images(new)\MuseumSpecimens\DBG\DBG_Specimens\DBG_ToBeRenamed
perl Q:\Research\Images(new)\MuseumSpecimens\DBG\DBG_Specimens\zbar\barcode.pl

I want to modify the bat file so that it runs the perl script on each sub directory within the directory (each folder within DBG_ToBe_Renamed) in this case. So far I have the following, but it isn't quite right.

FOR /R Q:\Research\Images(new)\MuseumSpecimens\DBG\DBG_Specimens\test\ %%G IN (.) DO perl Q:\Research\Images(new)\MuseumSpecimens\DBG\DBG_Specimens\zbar\barcode.pl

Thanks, I appreciate any help.

If it helps, the perl script reads barcodes from JPEGs and creates new files with the JPEG and associated RAW file renamed using the barcode value (https://github.com/psweeney-YU/reBar/blob/master/reBar.pl)

Upvotes: 1

Views: 140

Answers (1)

Holli
Holli

Reputation: 5072

This should work:

for /D %%d in (Q:\Research\Images(new)\MuseumSpecimens\DBG\DBG_Specimens\DBG_ToBeRenamed\*) do pushd %%d && perl Q:\Research\Images(new)\MuseumSpecimens\DBG\DBG_Specimens\zbar\barcode.pl && popd

Upvotes: 1

Related Questions