RENAME or REN with a date and time stamp

Hi -

I am using WS_FTP PRO which allows for executing a Dos script.  Can I use the REN or RENAME command to append the system date and time to the end of the filename I am downloading.

REN file1.txt file1.11172003134700.txt

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.

How about copy filename +/b
This will update the time stamp to the current
Oops - I now understand what you're looking for - yes.
This 'may' work for you:  ren file1.txt *.%date%.*

Otherwise, a small script may be in order:

for /f "tokens=1-3 delims=/" %%a in ('date/t') do (
set newfile=%%a%%b%%c
ren file1.txt file1.%newfile%.txt
Now I further understand (man what was I smokin' yesterday?!)

To append both the date AND time to your file, try this one:

To pull just the hour and minute, proceed as follows:
for /f "tokens=1-3 delims=/" %%a in ('date/t') do (
set strDate=%%a%%b%%c

REM  Note the space after delims=: in the line below
for /f "tokens=1-2 delims=: " %%i in ('time/t') do (
set newfile=%strDate%%%i%%j
ren file1.txt file1.%newfile%.txt

Otherwise, if you're looking for seconds as well, create a mini-batch file like this:
echo.|time|find "current" > tresults.txt

then replace the "time" section above with:
for /f "tokens=5-8 delims=:. " %%w in ('ttest.cmd') do (
set newfile=%strDate%%%w%%x%%y%%z

Good luck!
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.


One more way to skin the cat...

set OLDNAME=%1
set HH=%time:~0,2%
set MM=%time:~3,2%
set SS=%time:~6,2%
set MM=%date:~4,2%
set DD=%date:~7,2%
set YYYY=%date:~10,4%

for /f "delims=." %%a in ("%OLDNAME%") do set NEWNAME=%%a.%TIMESTAMP%.%%b



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
mtgcpcAuthor Commented:
Thanks to both of you for responding.
Brianadkins answer only works for a system with an American date format, so be careful!

What other formats does %date% come in (i.e. other languages) ?

You may need to swap variables around if the year is listed first (but that would apply to all solutions above, nit just mine)

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.