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

Author Topic: Verify Directory  (Read 3084 times)

0 Members and 1 Guest are viewing this topic.

yowy777

    Topic Starter


    Starter

    • Experience: Beginner
    • OS: Unknown
    Verify Directory
    « on: July 15, 2012, 02:07:31 PM »
    I have this batch:
    Code: [Select]
    @echo
    Color f0
    cd C:\Music\Game\
    md BGMBackup
    md bgmoriginal
    cd C:\
    copy C:\Music\Game\bgm\* C:\Music\Game\BGMBackup
    copy C:\Music\Game\bgm\* C:\Music\Game\BGMOriginal
    color f2
    echo: Process Finished
    TIMEOUT 3

    I want to add a code that checks for for C:\Music\Game\BGMBackup
    If it's there i want it to Stop the batch and not to do the backup. And a Display message that says Backup is already created, Cancelling operation...

    I am sorry for the trouble...
    « Last Edit: July 15, 2012, 02:32:45 PM by yowy777 »

    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    Re: Verify Directory
    « Reply #1 on: July 15, 2012, 02:18:46 PM »
    Code: [Select]
    @echo
    Color f0
    If exist "C:\Music\Game\BGMBackup\" (
    echo Backup is already created, Cancelling operation...
    goto :EOF
    )
    cd C:\Music\Game\
    md BGMBackup
    md bgmoriginal
    cd C:\
    copy C:\Music\Game\bgm\* C:\Music\Game\BGMBackup
    copy C:\Music\Game\bgm\* C:\Music\Game\BGMOriginal
    color f2
    echo: Process Finished
    TIMEOUT 3

    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    Re: Verify Directory
    « Reply #2 on: July 15, 2012, 02:22:31 PM »
    This should do the same thing as your code but be a little more robust and also handle long pathnames.

    Code: [Select]
    @echo
    Color f0
    If exist "C:\Music\Game\BGMBackup\" (
    echo Backup is already created, Cancelling operation...
    goto :EOF
    )
    echo Creating backup... please wait
    md "C:\Music\Game\BGMBackup" 2>nul
    md "C:\Music\Game\bgmoriginal" 2>nul
    copy /b "C:\Music\Game\bgm\*" "C:\Music\Game\BGMBackup" >nul
    copy /b "C:\Music\Game\bgm\*" "C:\Music\Game\BGMOriginal" >nul
    color f2
    echo: Process Finished
    TIMEOUT 3

    yowy777

      Topic Starter


      Starter

      • Experience: Beginner
      • OS: Unknown
      Re: Verify Directory
      « Reply #3 on: July 15, 2012, 02:33:30 PM »
      Thnx :) i really needed that!!