

InterviewSolution
Saved Bookmarks
1. |
Solve : I need a log after execution of my batch script. Please help!? |
Answer» <html><body><strong>Hello, I have a script, <a href="https://interviewquestions.tuteehub.com/tag/greg-477121" style="font-weight:bold;" target="_blank" title="Click to know more about GREG">GREG</a> gave me I think. The <a href="https://interviewquestions.tuteehub.com/tag/batch-893737" style="font-weight:bold;" target="_blank" title="Click to know more about BATCH">BATCH</a> script copy all the files from drives, for example if I want to copy all JPEG from D <a href="https://interviewquestions.tuteehub.com/tag/drive-959713" style="font-weight:bold;" target="_blank" title="Click to know more about DRIVE">DRIVE</a>, it copies all of JPEGs from D drive and so on. The thing I am looking for is when the script <a href="https://interviewquestions.tuteehub.com/tag/completes-2532986" style="font-weight:bold;" target="_blank" title="Click to know more about COMPLETES">COMPLETES</a> 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.</strong><br/><br/><br/><br/> Code: <a>[Select]</a>echo off<br/>SETLOCAL EnableDelayedExpansion<br/>set destfolder=D:\copiedjpegs<br/>set searchdrive="E:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.xls /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="E:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.jp*g /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="E:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.doc /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="F:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.xls /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="F:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.jp*g /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="F:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.doc /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="D:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.jp*g /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="D:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.xls /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="D:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.doc /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="G:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.doc /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="G:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.xls /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="G:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.jp*g /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="E:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.flv /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="F:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.flv /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="D:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.flv /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="G:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.flv /s /b') do copy "%%P" %Desktop%<br/><br/><br/><br/>If the script is copying from D, E, F, and G drive, I need four different log sheet with copied file details.<br/><br/><br/>C:\\test>type logcp.bat<br/><br/>rem Use with command line arguments<br/>rem Usage: logcp.bat c:\\ xls<br/>rem I used echo for copy. ( you must replace. )<br/><br/>echo off<br/>set /a cnt=0<br/>SETLOCAL EnableDelayedExpansion<br/>set destfolder=D:\\copiedjpegs<br/>set searchdrive=\"%1\"<br/>for /f \"delims=\" %%i in (\'dir %searchdrive%*.%2 /s /b\') do (<br/>echo %%i<br/>set /a cnt=!cnt! + 1<br/>)<br/>echo cnt=%cnt% > cplog.log<br/>echo %DATE% %TIME% >> cplog.log<br/>echo type cplog.log<br/>type cplog.log<br/><br/><br/>C:\\test>logcp.bat c:\\ xls<br/><br/>C:\\test>rem Use with command line arguments<br/><br/>C:\\test>rem Usage: logcp.bat c:\\ xls<br/><br/>C:\\test>rem I used echo for copy. ( you must replace. )<br/>c:\\Office2003SP3Changes\\Office2003_SP3Changes.xls<br/>c:\\Program Files\\Microsoft Office\\OFFICE11\\1033\\PROTTPLN.XLS<br/>c:\\Program Files\\Microsoft Office\\OFFICE11\\1033\\PROTTPLV.XLS<br/>c:\\Program Files\\Microsoft Office\\OFFICE11\\1033\\XL8GALRY.XLS<br/>c:\\Program Files\\Microsoft Office\\OFFICE11\\SAMPLES\\SOLVSAMP.XLS<br/>c:\\Program Files\\Microsoft Office\\Office12\\1033\\PROTTPLN.XLS<br/>c:\\Program Files\\Microsoft Office\\Office12\\1033\\PROTTPLV.XLS<br/>c:\\Windows\\Installer\\$PatchCache$\\Managed\\9040211900063D11C8EF10054038389C\\11.0.5614\\XL9GALRY.XLS_1033<br/>c:\\Windows\\ShellNew\\EXCEL9.XLS<br/>type cplog.log<br/>cnt=9<br/>Sat 08/07/2010 15:55:41.82<br/>C:\\test>I had too many \\ backslashes with my IE8 Browser above. I used echo for copy below.<br/>You must <a href="https://interviewquestions.tuteehub.com/tag/change-238106" style="font-weight:bold;" target="_blank" title="Click to know more about CHANGE">CHANGE</a> echo to copy and use source and destination.<br/><br/></body></html> | |