|
Answer» I'm in the process of LEARNING DOS.
In its simplest form, i need to: 1. If there's a file that exists, i need to check it if it exists, if it does i need to rename it with a .txt extension and place it into a directory. then WRITE a note in log file.
2. if there isn't a file that doesn't exist, i need to create a directory. then write it in a log
3. i need to copy only modified files from one directory to another
If anyone can help it would be very much appreciated.
thanksdoes this make sense?
Code: [Select]If exist "c:\temp\MyPlace\*.*" ( rename *.* *.FIL >> m.log ) else ( md c:\temp\MyPlace >> m.log
xcopy m:\*.* c:\temp\MyPlace\*.* /d /y1. echo off if exist FILENAME ( ren FILENAME FILENAME.TXT Copy FILENAME.TXT DIRECTORY Echo File found. > log.txt ) 2. If there isn't a file that doesn't exist? So, you have a list of files that need to exist? Ok.
echo off set list=put the path to where the REQUIRED file names are in. Eg. Files.txt setlocal enabledelayedexpansion for /f "delims=" %%a in (%list%) do ( Set /a COUNTER+=1 ) for /f "delims=" %%b in (%list%) do ( If exist %%a ( ren %%a %%a.txt Copy %%a.txt DIRECTORY echo File found > log.txt Set /a counter2+=1 ) ) If %counter% neq %counter2% ( Echo Not all files found. >log.txt Md DIRECTORY ) 3. Look at XCOPY /? at the command PROMPT. Also, try looking through the forum. You will probably find something to your requirements. thanks for this!
for #2. it's more like if FILENAME or DIRECTORY don't exist, create the directory (and the file) and write in a log file.
|