1.

Solve : I need a log after execution of my batch script. Please help!?

Answer» Hello, I have a script, GREG gave me I think. The BATCH script copy all the files from drives, for example if I want to copy all JPEG from D DRIVE, it copies all of JPEGs from D drive and so on. The thing I am looking for is when the script COMPLETES copying, I need a log showing this many files where copied on this date and time. Can anyone help me in this please. Down is the code of my script.



Code: [Select]echo off
SETLOCAL EnableDelayedExpansion
set destfolder=D:\copiedjpegs
set searchdrive="E:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.xls /s /b') do copy "%%P" %Desktop%
set searchdrive="E:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.jp*g /s /b') do copy "%%P" %Desktop%
set searchdrive="E:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.doc /s /b') do copy "%%P" %Desktop%
set searchdrive="F:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.xls /s /b') do copy "%%P" %Desktop%
set searchdrive="F:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.jp*g /s /b') do copy "%%P" %Desktop%
set searchdrive="F:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.doc /s /b') do copy "%%P" %Desktop%
set searchdrive="D:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.jp*g /s /b') do copy "%%P" %Desktop%
set searchdrive="D:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.xls /s /b') do copy "%%P" %Desktop%
set searchdrive="D:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.doc /s /b') do copy "%%P" %Desktop%
set searchdrive="G:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.doc /s /b') do copy "%%P" %Desktop%
set searchdrive="G:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.xls /s /b') do copy "%%P" %Desktop%
set searchdrive="G:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.jp*g /s /b') do copy "%%P" %Desktop%
set searchdrive="E:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.flv /s /b') do copy "%%P" %Desktop%
set searchdrive="F:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.flv /s /b') do copy "%%P" %Desktop%
set searchdrive="D:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.flv /s /b') do copy "%%P" %Desktop%
set searchdrive="G:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.flv /s /b') do copy "%%P" %Desktop%



If the script is copying from D, E, F, and G drive, I need four different log sheet with copied file details.


C:\\test>type   logcp.bat

rem Use with command line arguments
rem Usage: logcp.bat  c:\\  xls
rem I used echo for copy. ( you must replace. )

echo off
set /a cnt=0
SETLOCAL EnableDelayedExpansion
set destfolder=D:\\copiedjpegs
set searchdrive=\"%1\"
for /f \"delims=\" %%i in (\'dir %searchdrive%*.%2 /s /b\') do (
echo %%i
set /a cnt=!cnt! + 1
)
echo cnt=%cnt% >  cplog.log
echo %DATE%  %TIME%   >>  cplog.log
echo type cplog.log
type cplog.log


C:\\test>logcp.bat   c:\\  xls

C:\\test>rem Use with command line arguments

C:\\test>rem Usage: logcp.bat  c:\\  xls

C:\\test>rem I used echo for copy. ( you must replace. )
c:\\Office2003SP3Changes\\Office2003_SP3Changes.xls
c:\\Program Files\\Microsoft Office\\OFFICE11\\1033\\PROTTPLN.XLS
c:\\Program Files\\Microsoft Office\\OFFICE11\\1033\\PROTTPLV.XLS
c:\\Program Files\\Microsoft Office\\OFFICE11\\1033\\XL8GALRY.XLS
c:\\Program Files\\Microsoft Office\\OFFICE11\\SAMPLES\\SOLVSAMP.XLS
c:\\Program Files\\Microsoft Office\\Office12\\1033\\PROTTPLN.XLS
c:\\Program Files\\Microsoft Office\\Office12\\1033\\PROTTPLV.XLS
c:\\Windows\\Installer\\$PatchCache$\\Managed\\9040211900063D11C8EF10054038389C\\11.0.5614\\XL9GALRY.XLS_1033
c:\\Windows\\ShellNew\\EXCEL9.XLS
type cplog.log
cnt=9
Sat 08/07/2010  15:55:41.82
C:\\test>I had too many \\ backslashes with my IE8 Browser above. I used echo for copy below.
You must CHANGE echo to copy and use source and destination.



Discussion

No Comment Found