Append Todays date to a file name via batch file

I need to create a batch file that will append todays date to a file name and then move it to a different location.  I understand the basics of moving the file to a new location but I am a total loss of how to append date to the file.  An example would be

orders.txt --> orders_11-18-2003.txt
orders.txt --> orders_111803.txt

I am not to particular on the format as long as it is consistent.

Thanks in advance for the help
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


@echo off

for /f "tokens=2" %%v in ("%date%") do set dstring=%%v

set dstring=%dstring:/=-%

echo move orders.txt orders_%dstring%.txt


Remove the "echo" at the beginning of the move command when you are ready to go operational.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
neat tip. thanks!
I cant get this to work - it says the syntax is incorrect - I have used same code just different file names.

for /f "tokens=2" %%v in ("%date%") do set dstring=%%v
set dstring=%dstring:/=-%
move e:\db\test\oe_backups\file1.txt  e:\db\test\secure_backups\file2_%dstring%.txt
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.