Computing.Net > Forums > Disk Operating System > Renaming file to a variable value

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Renaming file to a variable value

Reply to Message Icon

Name: Michael Tham
Date: May 25, 2003 at 22:50:54 Pacific
OS: Win NT
CPU/Ram: Intel/256M
Comment:

Hi,

I would like to rename a file (which is copied from another location) to have the current date reflected in the filename. Please refer to below..

-------------
@echo off
for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set DATE=%%C%%A%%B
set DATE=%DATE:~2%
XCOPY \\sgsinjde05\c$\temp\r55410~1.csv e:\test /Z
REN e:\batch\r55410~1.csv "%DATE%".csv
-------------

I got the last line wrong, 'cos I'm not sure how to do it, please help.

Thanks in advance



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: May 26, 2003 at 16:36:56 Pacific
Reply:

The syntax of the command looks just fine, its logic is the one strange here...

From your batch file:

XCOPY \\sgsinjde05\c$\temp\r55410~1.csv e:\test /Z
REN e:\batch\r55410~1.csv "%DATE%".csv

You're copying a file A to a file B and trying to rename a file C, different than A and B. Perhaps that's the problem?

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br

______________________________________________________


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Renaming file to a variable value

Redirecting text file to a variable? www.computing.net/answers/dos/redirecting-text-file-to-a-variable/3566.html

Set number of lines from a file to a var www.computing.net/answers/dos/set-number-of-lines-from-a-file-to-a-var/6487.html

copy a file to a variable www.computing.net/answers/dos/copy-a-file-to-a-variable/12678.html