

InterviewSolution
Saved Bookmarks
1. |
Solve : Folder Transfer Batch File? |
Answer» <html><body><p>Quote from: Law506 on August 01, 2008, 09:43:09 PM</p><blockquote>What command would I throw into the batch file to have it <a href="https://interviewquestions.tuteehub.com/tag/output-344913" style="font-weight:bold;" target="_blank" title="Click to know more about OUTPUT">OUTPUT</a> in the text file how many FOLDERS it moved?</blockquote> <br/>echo off<br/>cls<br/>echo -------------------------------------------------------------------------------------------------------- >>Transfer.txt<br/>date /t >>Transfer.txt<br/>time /t >>Transfer.txt<br/>echo This will transfer all folders in SCAN to the ALPHABETICAL SCANNED DOCUMENTS.<br/>echo To stop the process CLOSE this window.<br/>echo <a href="https://interviewquestions.tuteehub.com/tag/list-11333" style="font-weight:bold;" target="_blank" title="Click to know more about LIST">LIST</a> of Files Moved. >>Transfer.txt<br/>pause<br/><br/>setlocal enabledelayedexpansion<br/>set Source=C:\Scanned Documents\<br/>set Target=C:\Alphabetical Scanned Documents\<br/><br/><strong>set /a foldersmoved=0</strong><br/><br/>for /f "tokens=*" %%a in ('dir "%Source%" /ad /b') do (<br/> set Current=%%a<br/> xcopy "%Source%\%%a" "%Target%\!Current:~0,1!\%%a\" /S /D /Y /C >>Transfer.txt<br/> <strong>set /a foldersmoved=!foldersmoved!+1</strong><br/> )<br/><br/>echo End Of Copy, see Transfer.txt for list of moved files.<br/>echo End Of Copy. >>Transfer.txt<br/><strong>echo Folders moved: %foldersmoved% >> Transfer.txt</strong><br/>pauseAwesome, works like a charm just like I expected.<br/><br/>Thanks Again. Quote from: Law506 on August 01, 2008, 09:43:09 PM<blockquote>hey,<br/>program appears to be working like a charm, can't thank yall enough. I have modifed it a bit to output to a text file for a kind of record keeping thing. What command would I throw into the batch file to have it output in the text file how many FOLDERS it moved? or is this possible? I would be happy I guess with the number of files moved if that one is possible. <br/><br/>Thanks guys, appreciate it.<br/><br/>If anyone knows off the top of thier head, I am <a href="https://interviewquestions.tuteehub.com/tag/looking-1079184" style="font-weight:bold;" target="_blank" title="Click to know more about LOOKING">LOOKING</a> around for the info now, how to setup an error log for a file not transfered to throw into the batch file that would be awesome.<br/><br/>Here is the file that has been compiled and modified slightly.<br/><br/> Code: <a>[Select]</a>echo off<br/>cls<br/>echo -------------------------------------------------------------------------------------------------------- >>Transfer.txt<br/>date /t >>Transfer.txt<br/>time /t >>Transfer.txt<br/>echo This will transfer all folders in SCAN to the ALPHABETICAL SCANNED DOCUMENTS.<br/>echo To stop the process CLOSE this window.<br/>echo List of Files Moved. >>Transfer.txt<br/>pause<br/><br/>setlocal enabledelayedexpansion<br/>set Source=C:\Scanned Documents\<br/>set Target=C:\Alphabetical Scanned Documents\<br/><br/>for /f "tokens=*" %%a in ('dir "%Source%" /ad /b') do (<br/> set Current=%%a<br/> xcopy "%Source%\%%a" "%Target%\!Current:~0,1!\%%a\" /S /D /Y /C >>Transfer.txt<br/> )<br/><br/>echo End Of Copy, see Transfer.txt for list of moved files.<br/>echo End Of Copy. >>Transfer.txt<br/>pause<br/></blockquote> <br/>for /f "tokens=*" %%a in ('dir "%Source%" /ad /b') do (<br/> set Current=%%a<br/> xcopy "%Source%\%%a" "%Target%\!Current:~0,1!\%%a\" /S /D /Y /C >>Transfer.txt<br/> If %<a href="https://interviewquestions.tuteehub.com/tag/errorlevel" style="font-weight:bold;" target="_blank" title="Click to know more about ERRORLEVEL">ERRORLEVEL</a>%==0 (<br/> GOTO :EOF<br/> ) else (<br/> Echo The following file completed with %errorlevel% >> errorlog.txt<br/> )<br/>)what "following file"? Can't quite see how the filename gets echoed.<br/> Quote from: Dias de verano on August 03, 2008, 09:00:02 AM<blockquote>what "following file"? Can't quite see how the filename gets echoed.<br/><br/></blockquote> <br/>Sorry should have read "following %%a"but the dir /ad in the loop makes %%a a folder, not a file. Quote from: Dias de verano on August 03, 2008, 10:49:18 AM<blockquote>but the dir /ad in the loop makes %%a a folder, not a file.<br/></blockquote> <br/>Yes you are <a href="https://interviewquestions.tuteehub.com/tag/correct-409949" style="font-weight:bold;" target="_blank" title="Click to know more about CORRECT">CORRECT</a> again. My bad for not reading the script carefully, I guess I was focused on the script that I posted and remember that the search was for .pdf's.<br/><br/>No I didn't make the assumption that the only files in any folder would be PDF's. But thanks again for pointing out my short sightedness DIAS.</body></html> | |