1.

Solve : Writing the results of a DOS program to a file?

Answer»

macdad, I don't think you understand what oba is TRYING to do.yes i dont know wat oba wants accomplished here

Code: [Select]for /f "tokens=* delims=" %%i in ('DIR /o:-d /s /b F:\sqldata\MSSQL\BACKUP\master\*.BAK') do (
copy %%i "\\C:\master"
goto endmstr1
)
:endmstr1

for /f "tokens=* delims=" %%i in ('dir /o:d /s /b Z:\master\*.*') do (
del %%i
goto endmstr2
)
:endmstr2Quote from: macdad- on May 16, 2008, 02:17:25 PM

yes i dont know wat oba wants accomplished here

In this code, he is looking into the folder F:\sqldata\MSSQL\BACKUP\master\ and all of its subfolders, and copying any .BAK file that may be there to the folder C:\master.

He is making dir SORT its output in reverse date order, why, I do not know.

Code: [Select]for /f "tokens=* delims=" %%i in ('dir /o:-d /s /b F:\sqldata\MSSQL\BACKUP\master\*.BAK') do (
copy %%i "\\C:\master"
goto endmstr1
)
:endmstr1

Here, he is deleting every file in every subdirectory below the directory Z:\master\. This time the dir output is sorted in date order, again, I do not know why.

Code: [Select]for /f "tokens=* delims=" %%i in ('dir /o:d /s /b Z:\master\*.*') do (
del %%i
goto endmstr2
)
:endmstr2
His eccentric use of labels is intriguing.

These 2 pieces are exactly EQUIVALENT to the above quoted code sections.

Code: [Select]for /f "tokens=* delims=" %%i in ('dir /o:-d /s /b F:\sqldata\MSSQL\BACKUP\master\*.BAK') do copy %%i "\\C:\master"
Code: [Select]for /f "tokens=* delims=" %%i in ('dir /o:d /s /b Z:\master\*.*') do del %%ithanks Dias, i always get lost in the For commandsThanks for all the input. I have the log I want now. I simple run a batch file that echoes the FIRST batch file's input to a log file.




Discussion

No Comment Found