copy and move files via batch file

Discussion in 'Software' started by Allochthonous, Sep 16, 2009.

  1. Allochthonous

    Allochthonous Corporal

    Here is the situation: I have a group of files that are dropped daily into a network folder. Lets call them DataFile_091509_A.xls, DataFile_091509_B.xls, and DataFile_091509_C.xls. I need to copy these files into an archive folder within the folder where these files are dropped, then move them to a local folder, while renaming them to a standard filename, ex DataFile_A.xls, DataFile_B.xls, DataFile_C.xls. I will overwrite the destination file names each day so that it inlcudes the most recent data.

    Here is what I have so far:

    REM Copy all datafiles into the Archive folder
    copy "\\PATH\*A.xls" "\\PATH\Archive" /y
    copy "\\PATH\*B.xls" "\\PATH\Archive" /y
    copy "\\PATH\*C.xls" "\\PATH\Archive" /y
    REM Move A
    move /y "\PATH\*A.xls" "c:\DataFile_A.xls"
    REM
    REM Move B
    move /y "\PATH\*B.xls" "c:\DataFile_B.xls"
    REM
    REM Move C
    move /y "\PATH\*C.xls" "c:\DataFile_C.xls"
    REM
    REM

    Now, this works just fine, but have I allowed enough room for error? Should I include something in my MOVE that will only move the most recent version of the file in case something goes wrong the day before and files are not moved properly? Should I include a delete to clear out the folder after the move?

    Any other suggestions?


    PK
     
  2. GermanOne

    GermanOne Guest

    I think it's okay. But you could use
    Code:
    if exist ...
    
    or
    Code:
    if not exist ...
    
    to figure out and show an error message.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds