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.
job to check if file exists
Moderator: DosItHelp
Re: job to check if file exists
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
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.