Batch IF ELSE commands help please
Posted: 16 Oct 2009 23:00
I'm in high school and working on making a batch file that does this:
Navigate to windows directory
Look for a file named problem.txt
if it exists, rename it to problem.old and display this message: File has been found and renamed
if it does not exist, display this message: problem.txt is not found
and change the working directory to c:\users using a relative path
This is what I have so far, and i just can't get it to work, very frustrating since this is my first time doing DOS.
@echo off
cd \
cd windows
IF EXIST problem.txt (GOTO :true) ELSE GOTO :false
:TRUE
rename c:\problem.txt problem.old
echo File has been found and renamed
:False
echo problem.txt is not found
Navigate to windows directory
Look for a file named problem.txt
if it exists, rename it to problem.old and display this message: File has been found and renamed
if it does not exist, display this message: problem.txt is not found
and change the working directory to c:\users using a relative path
This is what I have so far, and i just can't get it to work, very frustrating since this is my first time doing DOS.
@echo off
cd \
cd windows
IF EXIST problem.txt (GOTO :true) ELSE GOTO :false
:TRUE
rename c:\problem.txt problem.old
echo File has been found and renamed
:False
echo problem.txt is not found