+ Post New Thread
Results 1 to 3 of 3
Scripts Thread, BAT: Can someone please add a simple file present check before the delete file line? in Coding and Web Development; We have a script (below) that copies all the files from our Flip Video Cameras to a network share and ...
  1. #1

    Join Date
    Aug 2007
    Posts
    817
    Thank Post
    99
    Thanked 65 Times in 47 Posts
    Rep Power
    26

    BAT: Can someone please add a simple file present check before the delete file line?

    We have a script (below) that copies all the files from our Flip Video Cameras to a network share and then deletes the files from the camera.....

    BUT if there is a problem copying the files (i.e quota) then it still carries on and deletes the files.

    Could someone please suggest an ammendment to check that the files are copied before it deletes?

    Thanks in advance!

    Code:
    @echo off
    MODE CON: COLS=75 LINES=20
    COLOR 1F
    title Copying Files from Flip Camera
    echo Copying Files from Camera to O: Drive.....
    
    for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set dt=%%i-%%j-%%k-%%l
    for /f "Tokens=1" %%i in ('time /t') do set tm=-%%i
    set tm=%tm::=-%
    set dtt=%dt%%tm%
    Set "sourcefolder=E:\DCIM\100VIDEO"
    Set "destinationfolder=O:\PE\Student Videos"
    For %%a in ("%sourcefolder%\*.*") Do If exist "%%a" (
    xcopy /q /s /c /d /i /y "%%a" "%destinationfolder%\%dtt%-%%~na.*"
    )
    
    COLOR CF
    PING 1.1.1.1 -n 1 -w 3400 >NUL
    COLOR AF
    
    echo Removing files from camera....
    PING 1.1.1.1 -n 1 -w 2400 >NUL
    
    del /q E:\DCIM\100VIDEO\*.AVI
    CLS
    PING 1.1.1.1 -n 1 -w 2400 >NUL
    
    echo Files copied to O: Drive and removed from camera.....
    
    PING 1.1.1.1 -n 1 -w 2400 >NUL 
    Echo Remove Camera and press any key 
    pause

  2. #2


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,013
    Thank Post
    230
    Thanked 2,696 Times in 1,991 Posts
    Rep Power
    791
    You could check XCopy's errorlevel and then skip the delete part of your script if it doesn't equal zero.

    Code:
    IF %ERRORLEVEL% NEQ 0 GOTO abort
    Code:
    XCopy Error Levels
    0 success
    1 no files found to copy
    2 aborted by ^C
    4 initialization error (not enough memory or disk space, invalid drive, or syntax error)
    5 disk write error

  3. Thanks to Arthur from:

    burgemaster (23rd March 2011)

  4. #3

    Join Date
    Aug 2007
    Posts
    817
    Thank Post
    99
    Thanked 65 Times in 47 Posts
    Rep Power
    26
    IF %ERRORLEVEL% NEQ 0 GOTO abort

    added and working !
    Thanks !!!

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 9
    Last Post: 12th February 2011, 04:18 PM
  2. Bat file coding
    By tommccann in forum Windows
    Replies: 5
    Last Post: 31st March 2010, 11:41 AM
  3. Replies: 9
    Last Post: 9th April 2009, 07:33 AM
  4. BAT File issue
    By Danny159 in forum Windows Vista
    Replies: 2
    Last Post: 14th March 2009, 01:54 PM
  5. Replies: 4
    Last Post: 23rd March 2006, 06:27 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •