(SOLVED) .bat If Then statement

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jmituzas
Posts: 13
Joined: 30 Aug 2010 08:43

(SOLVED) .bat If Then statement

#1 Post by jmituzas » 31 Aug 2010 11:15

I need help with writing a batch script for

if file newfile.txt exists
then del "InDesignData.txt" ren "newfile.txt" "InDesignData.txt"

Thanks in advance, Joe
Last edited by jmituzas on 31 Aug 2010 11:34, edited 1 time in total.

jmituzas
Posts: 13
Joined: 30 Aug 2010 08:43

Re: .bat If Then statement

#2 Post by jmituzas » 31 Aug 2010 11:33

Solved

if not exist newfile.txt goto skip
del "InDesignData.txt"
ren "newfile.txt" "InDesignData.txt"
:skip

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: (SOLVED) .bat If Then statement

#3 Post by orange_batch » 31 Aug 2010 16:09

You could also,

Code: Select all

if exist newfile.txt (
del "InDesignData.txt"
ren "newfile.txt" "InDesignData.txt"
)


or,

Code: Select all

if exist newfile.txt del "InDesignData.txt"&&ren "newfile.txt" "InDesignData.txt"

miskox
Posts: 630
Joined: 28 Jun 2010 03:46

Re: (SOLVED) .bat If Then statement

#4 Post by miskox » 01 Sep 2010 04:52

Or

Code: Select all

if exist "newfile.txt" move /y "newfile.txt" "InDesignData.txt"



Saso

Post Reply