job to check if file exists

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
donkarnash
Posts: 1
Joined: 16 Nov 2006 20:25

job to check if file exists

#1 Post by donkarnash » 16 Nov 2006 20:31

Hello,
We will be getting 2 files every 5 mins (called wap1.txt & wap2) and I have to write a batch job to rename these files to (data1.txt & data2.txt) and move the current files (data1.txt & data2.txt) to another folder

so every 5 mins there will be 2 files
wap1.txt
wap2.txt

check if data1.txt & data2.txt >> IF EXISTS move them to processed with current time stamp

rename wap1.txt & wap2.txt as data1.txt & data2.txt

Can anyone please help me with the file. Thanks a lot.

Matice
Posts: 14
Joined: 14 Nov 2006 02:48

Re: job to check if file exists

#2 Post by Matice » 17 Nov 2006 02:50

greets

here is something you could work with
=8<=
@echo off
cls
REM create date variable strings
REM you need to adjust this in accordance to your own locale
for /F "tokens=1-4 delims=. " %%i IN ('date /t') DO (
set dd=%%i
set mm=%%j
set yy=%%k)
REM set /a dd=%dd% - 1
rem set da=%%i
REM echo %dd% %mm% %yy%

if exist c:\mypath\myfile.txt
move c:\mypath\myfile.txt c:\otherpath\myfile_%dd%_%mm%_%yy%.txt
=8<=


regards
Matice



donkarnash wrote:Hello,
We will be getting 2 files every 5 mins (called wap1.txt & wap2) and I have to write a batch job to rename these files to (data1.txt & data2.txt) and move the current files (data1.txt & data2.txt) to another folder

so every 5 mins there will be 2 files
wap1.txt
wap2.txt

check if data1.txt & data2.txt >> IF EXISTS move them to processed with current time stamp

rename wap1.txt & wap2.txt as data1.txt & data2.txt

Can anyone please help me with the file. Thanks a lot.

Post Reply