Solved batch script to copy log files from server to desktop

September 28, 2013 at 12:40:30
Specs: Windows Vista
hi
i am complete new to batch scripting ..

i need to create batch file to copy log files from some servers to local machine desktop in zip format.
here is what i have but it doesnt work...


@ECHO OFF
SET srcdir=D:\IIS LOGS
SET tgtdir=D:\FileCopy
FOR /F "tokens=*" %%F IN ('DIR /A-D /OD /TW /B "%srcdir%"')
SETLOCAL EnableDelayedExpansion
COPY "%srcdir%\%%F" "%tgtdir%"
7za.exe a -tzip ex%1-logs.zip %2\ex%1*.log
PAUSE
ENDLOCAL
)


See More: batch script to copy log files from server to desktop

Report •

#1
September 28, 2013 at 18:00:47
✔ Best Answer
@ECHO OFF & SETLOCAL EnableDelayedExpansion

SET srcdir=D:\IIS LOGS
SET tgtdir=D:\FileCopy
FOR /F "tokens=*" %%F IN ('DIR /A-D /OD /TW /B "%srcdir%"') do (
COPY "%srcdir%\%%F" "%tgtdir%"
:: not sure about this part.. you should be able to zip the files from their source without the copy, directly to their destination using -o.
7za.exe a -tzip ex%1-logs.zip %2\ex%1*.log
)


Report •
Related Solutions


Ask Question