1.

Solve : Folder Transfer Batch File?

Answer»

Quote from: Law506 on August 01, 2008, 09:43:09 PM

What command would I throw into the batch file to have it OUTPUT in the text file how many FOLDERS it moved?

echo off
cls
echo -------------------------------------------------------------------------------------------------------- >>Transfer.txt
date /t >>Transfer.txt
time /t >>Transfer.txt
echo This will transfer all folders in SCAN to the ALPHABETICAL SCANNED DOCUMENTS.
echo To stop the process CLOSE this window.
echo LIST of Files Moved. >>Transfer.txt
pause

setlocal enabledelayedexpansion
set Source=C:\Scanned Documents\
set Target=C:\Alphabetical Scanned Documents\

set /a foldersmoved=0

for /f "tokens=*" %%a in ('dir "%Source%" /ad /b') do (
   set Current=%%a
   xcopy "%Source%\%%a" "%Target%\!Current:~0,1!\%%a\" /S /D /Y /C >>Transfer.txt
   set /a foldersmoved=!foldersmoved!+1
   )

echo End Of Copy, see Transfer.txt for list of moved files.
echo End Of Copy. >>Transfer.txt
echo Folders moved: %foldersmoved% >> Transfer.txt
pauseAwesome, works like a charm just like I expected.

Thanks Again. Quote from: Law506 on August 01, 2008, 09:43:09 PM
hey,
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. 

Thanks guys, appreciate it.

If anyone knows off the top of thier head, I am LOOKING 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.

Here is the file that has been compiled and modified slightly.

Code: [Select]echo off
cls
echo -------------------------------------------------------------------------------------------------------- >>Transfer.txt
date /t >>Transfer.txt
time /t >>Transfer.txt
echo This will transfer all folders in SCAN to the ALPHABETICAL SCANNED DOCUMENTS.
echo To stop the process CLOSE this window.
echo List of Files Moved. >>Transfer.txt
pause

setlocal enabledelayedexpansion
set Source=C:\Scanned Documents\
set Target=C:\Alphabetical Scanned Documents\

for /f "tokens=*" %%a in ('dir "%Source%" /ad /b') do (
   set Current=%%a
   xcopy "%Source%\%%a" "%Target%\!Current:~0,1!\%%a\" /S /D /Y /C >>Transfer.txt
   )

echo End Of Copy, see Transfer.txt for list of moved files.
echo End Of Copy. >>Transfer.txt
pause

for /f "tokens=*" %%a in ('dir "%Source%" /ad /b') do (
   set Current=%%a
   xcopy "%Source%\%%a" "%Target%\!Current:~0,1!\%%a\" /S /D /Y /C >>Transfer.txt
   If %ERRORLEVEL%==0 (
                GOTO :EOF
    ) else (
                Echo The following file completed with %errorlevel% >> errorlog.txt
    )
)what "following file"? Can't quite see how the filename gets echoed.
Quote from: Dias de verano on August 03, 2008, 09:00:02 AM
what "following file"? Can't quite see how the filename gets echoed.


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
but the dir /ad in the loop makes %%a a folder, not a file.

Yes you are CORRECT 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.

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.


Discussion

No Comment Found