|
Question : MS DOS looping
|
|
I am needing to run the following in a MS DOS bacth file:
net use x:\\hippo\login_rpt\Data set p1=%comspec% /C if not @ISDIR set p2=del 0x22x:\@FILE0x22 set days=-30 FORFILES /P x:\ /D %days% /C "%p1%==TRUE %p2%" net use x: /delete
net use x:\\lamb\login_rpt\Data set p1=%comspec% /C if not @ISDIR set p2=del 0x22x:\@FILE0x22 set days=-30 FORFILES /P x:\ /D %days% /C "%p1%==TRUE %p2%" net use x: /delete
net use x:\\tuttle\login_rpt\Data set p1=%comspec% /C if not @ISDIR set p2=del 0x22x:\@FILE0x22 set days=-30 FORFILES /P x:\ /D %days% /C "%p1%==TRUE %p2%" net use x: /delete
net use x:\\baltar\login_rpt\Data set p1=%comspec% /C if not @ISDIR set p2=del 0x22x:\@FILE0x22 set days=-30 FORFILES /P x:\ /D %days% /C "%p1%==TRUE %p2%" net use x: /delete
How can this be simplified so I am not repeating the code between the net use commands?
|
|
Answer : MS DOS looping
|
|
Try this:
@echo off setlocal for %%a in (hippo lamb tuttle baltar) do call :process %%a goto :eof :: *** Subroutine process: :process set Machine=%1 net use x:\\%Machine%\login_rpt\Data set p1=%comspec% /C if not @ISDIR set p2=del 0x22x:\@FILE0x22 set days=-30 FORFILES /P x:\ /D %days% /C "%p1%==TRUE %p2%" net use x: /delete goto :eof
|
|
|