Computer Hope

Microsoft => Microsoft DOS => Topic started by: yowy777 on July 16, 2012, 09:40:11 PM

Title: Problem on If exist...
Post by: yowy777 on July 16, 2012, 09:40:11 PM
This is my code:
Quote
@echo off
MODE CON: COLS=80 LINES=20
Color f0
if exist /BGMBackup/ goto :continue else goto :backup
:backup
md "BGMBackup" 2>nul
md "BGMOriginal" 2>nul
copy /b "\bgm\*" "\BGMBackup"
copy /b "\bgm\*" "\BGMOriginal"
TIMEOUT 5 >nul
if exist \BGMBackup goto :edit
:continue
Color f0
copy /b "\BGMOriginal\*" "\BGM\"
start MyLauncher.exe
TIMEOUT 16 >nul
copy /b "\bgmedit\*" "\BGM\"
COLOR f2
echo: You can now start!!
TIMEOUT 5 >nul
exit
:editado
Color f0
start MyLauncher.exe
TIMEOUT 16 >nul
copy /b "\bgmedit\*" "\BGM\"
COLOR f2
echo: You can now start!!
TIMEOUT 5 >nul
exit
I want to check if the folder is there... but i don't know the code ...
Title: Re: Problem on If exist...
Post by: foxidrive on July 17, 2012, 02:41:20 AM
Quote
if exist /BGMBackup/ goto :continue else goto :backup

The line above should be expressed like this.

if exist "\BGMBackup\" (goto :continue) else (goto :backup)


Your code creates folders in the current directory but then copies file explicitly to root folders.  That's a recipe for failure.
Change the MD commands so they create root folders too.