Page 1 of 1

job to check if file exists

Posted: 16 Nov 2006 20:31
by donkarnash
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.

Re: job to check if file exists

Posted: 17 Nov 2006 02:50
by Matice
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.