1.

Solve : Copy the last modified file using batch File?

Answer»

Hi any one can help me on my problem??
when i run my batch file this ERROE comes out,

@ECHO off

setlocal
set srcDir=C:\Paul1\
set destDir=C:\Paul2\
set lastmod=
pushd "%srcDir%"
for /f "TOKENS=*" %%a in ('dir /b /od 2^>NUL') do SET lastmod=%%a
%%a was unexpected at this time.
if "%lastmod%"==""
The syntax of the command is INCORRECT.
echo Could not locate files.&goto :eof
copy "%lastmod%" "%destdir%"
The system cannot find the file specified.

kindly tell me whats wrong with it.

Advance Thanks!
Cheers!

PaulkanTry this - the errors didn't SEEM to all apply to your code.

Code: [Select]@echo off
setlocal
set "srcDir=C:\Paul1\"
set "destDir=C:\Paul2\"
set "lastmod="
pushd "%srcDir%"
for /f "delims=" %%a in ('dir /b /od /a-d 2^>NUL') do SET "lastmod=%%a"
if not defined lastmod (echo Could not locate files.&goto :eof)
copy "%lastmod%" "%destdir%"
popd



Discussion

No Comment Found