Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Folder Transfer Batch File  (Read 9046 times)

0 Members and 1 Guest are viewing this topic.

Dias de verano

  • Guest
Re: Folder Transfer Batch File
« Reply #15 on: August 01, 2008, 11:33:55 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
pause

Law506

    Topic Starter


    Greenhorn

    Re: Folder Transfer Batch File
    « Reply #16 on: August 02, 2008, 11:25:58 PM »
    Awesome, works like a charm just like I expected.

    Thanks Again.

    erobby



      Beginner

      • Experience: Experienced
      • OS: Linux variant
      Re: Folder Transfer Batch File
      « Reply #17 on: August 03, 2008, 08:51:25 AM »
      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
          )
      )

      Dias de verano

      • Guest
      Re: Folder Transfer Batch File
      « Reply #18 on: August 03, 2008, 09:00:02 AM »
      what "following file"? Can't quite see how the filename gets echoed.

      erobby



        Beginner

        • Experience: Experienced
        • OS: Linux variant
        Re: Folder Transfer Batch File
        « Reply #19 on: August 03, 2008, 09:04:07 AM »
        what "following file"? Can't quite see how the filename gets echoed.


        Sorry should have read "following %%a"

        Dias de verano

        • Guest
        Re: Folder Transfer Batch File
        « Reply #20 on: August 03, 2008, 10:49:18 AM »
        but the dir /ad in the loop makes %%a a folder, not a file.

        erobby



          Beginner

          • Experience: Experienced
          • OS: Linux variant
          Re: Folder Transfer Batch File
          « Reply #21 on: August 03, 2008, 04:46:49 PM »
          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.