We help IT Professionals succeed at work.

Urgent :Batch file for rename and copy the log file

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.

Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
Top Expert 2007

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

I hope this helps !


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
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.