A Windows XP help forum. PCbanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PCbanter forum » Microsoft Windows XP » General XP issues or comments
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

rename file tgrough bat file



 
 
Thread Tools Display Modes
  #1  
Old December 4th 08, 01:56 PM posted to microsoft.public.windowsxp.general
Natalia
external usenet poster
 
Posts: 9
Default rename file tgrough bat file

dear all, i have file 1.txt which i'd like to rename to 1_today_date. txt
in bat file. For example today is 04.12.2008, i'd like to rename 1.txt to
1_20081204.txt, is it possible? Or in another words how to put sysdate value
to variable.
Thank you.
Natalia.
Ads
  #2  
Old December 4th 08, 05:59 PM posted to microsoft.public.windowsxp.general
Pegasus \(MVP\)[_2652_]
external usenet poster
 
Posts: 1
Default rename file tgrough bat file


"Natalia" wrote in message
...
dear all, i have file 1.txt which i'd like to rename to 1_today_date.
txt
in bat file. For example today is 04.12.2008, i'd like to rename 1.txt to
1_20081204.txt, is it possible? Or in another words how to put sysdate
value
to variable.
Thank you.
Natalia.


It depends on your date format. Click Start / Run / cmd {OK}, then type this
command:
echo %date%{Enter}
What do you see?


  #3  
Old December 5th 08, 06:12 AM posted to microsoft.public.windowsxp.general
Natalia
external usenet poster
 
Posts: 9
Default rename file tgrough bat file


"Pegasus (MVP)" wrote:


"Natalia" wrote in message
...
dear all, i have file 1.txt which i'd like to rename to 1_today_date.
txt
in bat file. For example today is 04.12.2008, i'd like to rename 1.txt to
1_20081204.txt, is it possible? Or in another words how to put sysdate
value
to variable.
Thank you.
Natalia.


It depends on your date format. Click Start / Run / cmd {OK}, then type this
command:
echo %date%{Enter}
What do you see?




hello, thank you very much for your answer.
i see: 05.12.2008
  #4  
Old December 5th 08, 07:48 AM posted to microsoft.public.windowsxp.general
Pegasus \(MVP\)[_2660_]
external usenet poster
 
Posts: 1
Default rename file tgrough bat file


"Natalia" wrote in message
...

"Pegasus (MVP)" wrote:


"Natalia" wrote in message
...
dear all, i have file 1.txt which i'd like to rename to 1_today_date.
txt
in bat file. For example today is 04.12.2008, i'd like to rename 1.txt
to
1_20081204.txt, is it possible? Or in another words how to put sysdate
value
to variable.
Thank you.
Natalia.


It depends on your date format. Click Start / Run / cmd {OK}, then type
this
command:
echo %date%{Enter}
What do you see?




hello, thank you very much for your answer.
i see: 05.12.2008


OK. Try this:
@echo off
ren 1.txt "1_%date:.=%.txt"

or perhaps this:
@echo off
for /F "delims=. tokens=1-3" %%a in ('echo %date%') do ren 1.txt
"1_%%c%%b%%a.txt"

Note that line2 is a long line. Do not break it up!


  #5  
Old December 5th 08, 11:24 AM posted to microsoft.public.windowsxp.general
Natalia
external usenet poster
 
Posts: 9
Default rename file tgrough bat file



"Pegasus (MVP)" wrote:


"Natalia" wrote in message
...

"Pegasus (MVP)" wrote:


"Natalia" wrote in message
...
dear all, i have file 1.txt which i'd like to rename to 1_today_date.
txt
in bat file. For example today is 04.12.2008, i'd like to rename 1.txt
to
1_20081204.txt, is it possible? Or in another words how to put sysdate
value
to variable.
Thank you.
Natalia.

It depends on your date format. Click Start / Run / cmd {OK}, then type
this
command:
echo %date%{Enter}
What do you see?




hello, thank you very much for your answer.
i see: 05.12.2008


OK. Try this:
@echo off
ren 1.txt "1_%date:.=%.txt"

or perhaps this:
@echo off
for /F "delims=. tokens=1-3" %%a in ('echo %date%') do ren 1.txt
"1_%%c%%b%%a.txt"

Note that line2 is a long line. Do not break it up!




Both variants are working! Thank you very much!
  #6  
Old December 5th 08, 11:41 AM posted to microsoft.public.windowsxp.general
Pegasus \(MVP\)[_2663_]
external usenet poster
 
Posts: 1
Default rename file tgrough bat file


"Natalia" wrote in message
...


"Pegasus (MVP)" wrote:


"Natalia" wrote in message
...

"Pegasus (MVP)" wrote:


"Natalia" wrote in message
...
dear all, i have file 1.txt which i'd like to rename to
1_today_date.
txt
in bat file. For example today is 04.12.2008, i'd like to rename
1.txt
to
1_20081204.txt, is it possible? Or in another words how to put
sysdate
value
to variable.
Thank you.
Natalia.

It depends on your date format. Click Start / Run / cmd {OK}, then
type
this
command:
echo %date%{Enter}
What do you see?




hello, thank you very much for your answer.
i see: 05.12.2008


OK. Try this:
@echo off
ren 1.txt "1_%date:.=%.txt"

or perhaps this:
@echo off
for /F "delims=. tokens=1-3" %%a in ('echo %date%') do ren 1.txt
"1_%%c%%b%%a.txt"

Note that line2 is a long line. Do not break it up!




Both variants are working! Thank you very much!


Thanks for the feedback.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off






All times are GMT +1. The time now is 05:41 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 PCbanter.
The comments are property of their posters.