dagga007
asked on
cmd script to run in loop
The problem i have is if our application places 2 or 3 text files in a folder
when the batch script runs it renames all three text files with the same name envio.SND.
Windows will not alow 2 or 3 files with the same name in one folder. This is were i have a problem
Any help on this is appreciated
d:
cd mqsysmon\irr\work\ifcsum
copy *.txt d:\mqsysmon\irr\work\ifcsu m\backup /Y
rem *********File send II ***********
:DEBUTII
Del envoi.SND
ren *.TXT envoi.SND ""I need the script to look at the first file rename it and then loop back and look at the first file again as the first file is delete once used.""
IF EXIST envoi.SND goto SUITEII
goto FIN
:SUITEII
d:\mqsysmon\mqgen d:\mqsysmon\irr\work\ifcsu m\envoi.SN D 127949 1026 E CSQ1 IRL
goto DEBUTII
rem ********* Fin ***********
:FIN
when the batch script runs it renames all three text files with the same name envio.SND.
Windows will not alow 2 or 3 files with the same name in one folder. This is were i have a problem
Any help on this is appreciated
d:
cd mqsysmon\irr\work\ifcsum
copy *.txt d:\mqsysmon\irr\work\ifcsu
rem *********File send II ***********
:DEBUTII
Del envoi.SND
ren *.TXT envoi.SND ""I need the script to look at the first file rename it and then loop back and look at the first file again as the first file is delete once used.""
IF EXIST envoi.SND goto SUITEII
goto FIN
:SUITEII
d:\mqsysmon\mqgen d:\mqsysmon\irr\work\ifcsu
goto DEBUTII
rem ********* Fin ***********
:FIN
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Is there anyway to pause the script to view what is happing
::show commands as they're processing...
@echo on
::or inside your script...
:DEBUTII
del envoi.SND
for %%a in (*.txt) do (
ren %%~na *.SND
ping 127.0.0.1 -n 10
pause
)
@echo on
::or inside your script...
:DEBUTII
del envoi.SND
for %%a in (*.txt) do (
ren %%~na *.SND
ping 127.0.0.1 -n 10
pause
)
As sirbounty has shown, you can insert PAUSE commands anywhere in the script to pause the processing at those points. To continue the processing once a PAUSE command has been run, you can press any key.
Of course, simply turning on the echo (@echo on)
will reveal the processing
and while the
ping 127.0.0.1 -n 5
is running, you'll see the commands.
You can place a >null at the end to hide that one...
ping 127.0.0.1 -n 5 > null
The -n 5 says to repeat 5 times (roughly 5 seconds) - increase as desired
will reveal the processing
and while the
ping 127.0.0.1 -n 5
is running, you'll see the commands.
You can place a >null at the end to hide that one...
ping 127.0.0.1 -n 5 > null
The -n 5 says to repeat 5 times (roughly 5 seconds) - increase as desired
ASKER
for some reason it still wont pause, I added the line pause
to the end of the file
to the end of the file
Which script are you using now?
ASKER
your script
The entire script should look like this:
@echo on
d:
cd mqsysmon\irr\work\ifcsum
copy *.txt d:\mqsysmon\irr\work\ifcsu m\backup /Y
rem *********File send II ***********
:DEBUTII
del envoi.SND
for %%a in (*.txt) do (
ren %%~na *.SND
call d:\mqsysmon\mqgen d:\mqsysmon\irr\work\ifcsu m\envoi.SN D 127949 1026 E CSQ1 IRL
ping 127.0.0.1 -n 10
pause
)
@echo on
d:
cd mqsysmon\irr\work\ifcsum
copy *.txt d:\mqsysmon\irr\work\ifcsu
rem *********File send II ***********
:DEBUTII
del envoi.SND
for %%a in (*.txt) do (
ren %%~na *.SND
call d:\mqsysmon\mqgen d:\mqsysmon\irr\work\ifcsu
ping 127.0.0.1 -n 10
pause
)
ASKER
sorry its Darwinian999 script
Adjust it like this:
@echo on
rem Set an environment variable for the directory we are working with
set SRCDIR=d:\mqsysmon\irr\wor k\ifcsum
rem Copy the TXT files to a backup directory
copy %SRCDIR%\*.txt %SRCDIR%\backup /Y
rem Delete any previous file left by a failed run
if exist %SRCDIR%\envoi.SND del %SRCDIR%\envoi.SND
rem Process each of the TXT files one at a time using a subroutine
for %%X in (%SRCDIR%\*.txt) do call :SUITII %%X
goto FIN
:SUITEII
rem Rename the file passed as the first parameter to this subroutine
ren %SRCDIR%\%1 envoi.SND
pause
rem Process the file
d:\mqsysmon\mqgen %SRCDIR%\envoi.SND 127949 1026 E CSQ1 IRL
pause
rem Delete the file just processed
del %SRCDIR%\envoi.SND
rem End of the subroutine
GOTO :EOF
rem ********* Fin ***********
:FIN
rem Delete the environment variable we created
set SRCDIR=
@echo on
rem Set an environment variable for the directory we are working with
set SRCDIR=d:\mqsysmon\irr\wor
rem Copy the TXT files to a backup directory
copy %SRCDIR%\*.txt %SRCDIR%\backup /Y
rem Delete any previous file left by a failed run
if exist %SRCDIR%\envoi.SND del %SRCDIR%\envoi.SND
rem Process each of the TXT files one at a time using a subroutine
for %%X in (%SRCDIR%\*.txt) do call :SUITII %%X
goto FIN
:SUITEII
rem Rename the file passed as the first parameter to this subroutine
ren %SRCDIR%\%1 envoi.SND
pause
rem Process the file
d:\mqsysmon\mqgen %SRCDIR%\envoi.SND 127949 1026 E CSQ1 IRL
pause
rem Delete the file just processed
del %SRCDIR%\envoi.SND
rem End of the subroutine
GOTO :EOF
rem ********* Fin ***********
:FIN
rem Delete the environment variable we created
set SRCDIR=
ASKER
Still having problems pausing the script, I'm on a Windows server 2003, would that have something to do with it or maybe the version of dos?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How soon before that happens?
Would a simple delay suffice?
Something like:
:DEBUTII
del envoi.SND
for %%a in (*.txt) do (
ren %%~na *.SND
ping 127.0.0.1 -n 10
)