Date Parsing using cmd line scripting code FOR

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I would like to copy and rename a file with the system date (Window 2000 Professional OS) as the filename by using the FOR scripting code in a batch file

Here is my code

copy E:\tv63_share\loncprod.prn E:\tv63_share\????????2.pr
for /f "tokens=2-4 delims=/" %%a in ('DATE /T') do set Date=%%a%%b%%
E
cd tv63_shar
ren loncprod2.prn %Date

However, the FOR code used in the parsing date, I got only the day and the year; th month is missing. If I change the tokens=1-4, then I got the "Wed 05192004" with "Wed" in front of it. How can I get only 05192004 without the Wed so that I can use %Date% as my filename. Please help. Thanks in advance

-Gordon Chiu
 
Gordon Chiu said:
Hi,

I would like to copy and rename a file with the system date (Window
2000 Professional OS) as the filename by using the FOR scripting code
in a batch file.

Here is my codes

copy E:\tv63_share\loncprod.prn E:\tv63_share\????????2.prn
for /f "tokens=2-4 delims=/" %%a in ('DATE /T') do set Date=%%a%%b%%c
E:
cd tv63_share
ren loncprod2.prn %Date%

However, the FOR code used in the parsing date, I got only the day
and the year; th month is missing. If I change the tokens=1-4, then I
got the "Wed 05192004" with "Wed" in front of it. How can I get only
05192004 without the Wed so that I can use %Date% as my filename.
Please help. Thanks in advance.

I'd ask in one of the scripting groups if I were you - I don't think
it's on-topic in this group.
 
Hi Jon

I have tried to post it to the scripting group, but, it keeps showing up at the English Group. How can I do it? Please advise. Thank

-Gordo

----- Jon Skeet [C# MVP] wrote: ----

Gordon Chiu said:
Hi
2000 Professional OS) as the filename by using the FOR scripting cod
in a batch file
for /f "tokens=2-4 delims=/" %%a in ('DATE /T') do set Date=%%a%%b%%
E
cd tv63_shar
ren loncprod2.prn %Date
and the year; th month is missing. If I change the tokens=1-4, then
got the "Wed 05192004" with "Wed" in front of it. How can I get onl
05192004 without the Wed so that I can use %Date% as my filename
Please help. Thanks in advance

I'd ask in one of the scripting groups if I were you - I don't think
it's on-topic in this group
 
Gordon Chiu said:
I have tried to post it to the scripting group, but, it keeps showing
up at the English Group. How can I do it? Please advise. Thanks

I'm not sure what you mean by "the English Group" but I would suggest
using an NNTP newsreader instead of the web access - point your
newsreader (eg Outlook Express) at news.microsoft.com and you should be
able to easily post to the appropriate group that way.
 
Back
Top