Page 1 of 1

File process under each subfolder of a certain path

Posted: 25 Jun 2014 06:58
by autonicknan
Hello,

I want to create a bat file with which a specific action will be performed under all the subfolders of a certain path.

I have already made a file with which I can execute my action under a specific folder(C:\IPSL\T125\LM55786_UUS\SIPSTK\PARSING_MIDDLE\PARSING_MIDDLE10\main) individually:

echo off

cd C:\IPSL\T125\LM55786_UUS\SIPSTK\PARSING_MIDDLE\PARSING_MIDDLE10\main

del *.ITS
del *.TRC
del *.dbc

ipslc /B /p%toolpath%\ipsl\sip01\sip01.prf -cits -m "*.ctl"
ipslc /B /p%toolpath%\ipsl\sip01\sip01.prf -cits -m "*.scr"

echo
pause


The script above works fine but just for the files under the specific folder "PARSING_MIDDLE10\main".

What I need is this actions to be performed to all subfolders under "C:\IPSL\T125\LM55786_UUS\SIPSTK\PARSING_MIDDLE\".

I have modified the bat file as below but it does not work :(

echo off

cd C:\IPSL\T125\LM55786_UUS\SIPSTK\PARSING_MIDDLE\

for /r %%g in (.) do

del *.ITS
del *.TRC
del *.dbc

ipslc /B /p%toolpath%\ipsl\sip01\sip01.prf -cits -m "*.ctl"
ipslc /B /p%toolpath%\ipsl\sip01\sip01.prf -cits -m "*.scr"

echo
pause



Any idea;

Thanks
Nikos

Re: File process under each subfolder of a certain path

Posted: 25 Jun 2014 07:26
by foxidrive
Try this but backup your files first.

Code: Select all

echo off

for /d /r "C:\IPSL\T125\LM55786_UUS\SIPSTK\PARSING_MIDDLE" %%g in (*) do (
pushd "%%g"
echo "%%g"
del *.ITS
del *.TRC
del *.dbc

ipslc /B /p%toolpath%\ipsl\sip01\sip01.prf -cits -m "*.ctl"
ipslc /B /p%toolpath%\ipsl\sip01\sip01.prf -cits -m "*.scr"
popd
)
echo done
pause

Re: File process under each subfolder of a certain path

Posted: 25 Jun 2014 10:23
by autonicknan
Hello foxidrive,

This works...:)

Thank you very much!!!

Nikos