[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Urgent :Batch file for rename and copy the log file

Posted on 2007-10-01
Medium Priority
Last Modified: 2011-09-20
Hi all,
I have a log file called "hr_xms_interface_vb.log" in D:\hr_xms_prog.
I have batch file which runs every day and gives me this log file (hr_xms_interface_vb.log).
That part works fine.

 But now i want to copy this log file to D:\hr_xms_prog\hr_xms_interface_log_backup folder.
and to rename it as hr_xms_interface_vb_001.log(For back up purpose). Next time when i run the batch file, i want the latest log file as hr_xms_interface_vb_001.log and the previous log file as(old log file) hr_xms_interface_vb_002.log. and so on.
I have to keep 5 days log file as back up. So in 6 th time,hr_xms_interface_vb_005.log has to be deleted and all others to be renamed correspondingly.

Could you please help me to write a batch file for doing this?

Thanks in Advance.

Question by:noble123_2000
LVL 51

Accepted Solution

ahoffmann earned 2000 total points
ID: 19990962
del  D:\hr_xms_prog\hr_xms_interface_log_backup\hr_xms_interface_vb_005.log
move D:\hr_xms_prog\hr_xms_interface_log_backup\hr_xms_interface_vb_004.log D:\hr_xms_prog\hr_xms_interface_log_backup\hr_xms_interface_vb_005.log
move D:\hr_xms_prog\hr_xms_interface_log_backup\hr_xms_interface_vb_003.log D:\hr_xms_prog\hr_xms_interface_log_backup\hr_xms_interface_vb_004.log
move D:\hr_xms_prog\hr_xms_interface_log_backup\hr_xms_interface_vb_002.log D:\hr_xms_prog\hr_xms_interface_log_backup\hr_xms_interface_vb_003.log
move D:\hr_xms_prog\hr_xms_interface_log_backup\hr_xms_interface_vb_001.log D:\hr_xms_prog\hr_xms_interface_log_backup\hr_xms_interface_vb_002.log
copy hr_xms_interface_vb.log D:\hr_xms_prog\hr_xms_interface_log_backup\hr_xms_interface_vb_001.log
LVL 63

Expert Comment

ID: 19991248
Not sure if Move is the correct command, I would think that ren  ( rename )  would be more appropriate.

I hope this helps !

Author Comment

ID: 19996028
hi all,
Thanks Ahoffmann and SysExpert for your fast reply.
Ahoffmann , Your solution is Perfect and thanks a lot!

SysExpert , Move works fine for me...

Thanks all

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month19 days, 1 hour left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question