Nuggets
asked on
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
or
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
orders.txt --> orders_11-18-2003.txt
or
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
neat tip. thanks!
I cant get this to work - it says the syntax is incorrect - I have used same code just different file names.
setlocal
for /f "tokens=2" %%v in ("%date%") do set dstring=%%v
set dstring=%dstring:/=-%
move e:\db\test\oe_backups\file 1.txt e:\db\test\secure_backups\ file2_%dst ring%.txt
setlocal
for /f "tokens=2" %%v in ("%date%") do set dstring=%%v
set dstring=%dstring:/=-%
move e:\db\test\oe_backups\file
@echo off
setlocal
for /f "tokens=2" %%v in ("%date%") do set dstring=%%v
set dstring=%dstring:/=-%
echo move orders.txt orders_%dstring%.txt
--
mrdtn