Renaming ?

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.

Renaming ?

Postby azfar » Fri Mar 17, 2006 2:54 pm

How do I rename a file into current date and time ?
Azfar Hashmi
Email : azfarhashmi@hotmail.com
azfar
Captain
 
Posts: 598
Joined: Tue Mar 23, 2004 1:16 am
WLM: azfarhashmi@hotmail.com
Yahoo Messenger: azfarhusain@yahoo.com
Location: Karachi

Postby Kdaemon » Fri Mar 17, 2006 7:39 pm

Code: Select all

Ix tmp # mkdir test
Ix tmp # cd test
Ix test # ls
Ix test # touch abc
Ix test # mv abc "`date`"
Ix test # ls
Sun Mar 19 05:00:37 PKT 2006
Ix test #
reg linux user #298274
Kdaemon
Naib Subedar
 
Posts: 346
Joined: Sat Nov 30, 2002 12:22 pm
Location: Islamabad. GPS: LHR

Postby azfar » Sat Mar 18, 2006 12:01 pm

nice idea, trying it.
Azfar Hashmi

Email : azfarhashmi@hotmail.com
azfar
Captain
 
Posts: 598
Joined: Tue Mar 23, 2004 1:16 am
WLM: azfarhashmi@hotmail.com
Yahoo Messenger: azfarhusain@yahoo.com
Location: Karachi

Re:

Postby LinuxFreaK » Mon Mar 20, 2006 3:39 pm

Dear azfar,
Salam,

If you use file format like this then you can track it.

# mv abc "abc.`date`"

Best Regards.
Farrukh Ahmed
LinuxFreaK
Site Admin
 
Posts: 5132
Joined: Fri May 02, 2003 10:24 am
ICQ: 82075802
Website: http://www.linuxpakistan.net/wiki/index.php?pagename=LinuxFreak
WLM: f4fahmed@hotmail.com
Yahoo Messenger: f4fahmed@yahoo.com
AOL: linuxpakistan@aol.com
Location: Karachi

Postby azfar » Sat Jun 03, 2006 4:28 pm

Well its working fine on linux but now i need to do the same practice on windows 2000 box but i think no DATE variable there.
Any help.
Azfar Hashmi

Email : azfarhashmi@hotmail.com
azfar
Captain
 
Posts: 598
Joined: Tue Mar 23, 2004 1:16 am
WLM: azfarhashmi@hotmail.com
Yahoo Messenger: azfarhusain@yahoo.com
Location: Karachi

Postby lambda » Sun Jun 04, 2006 2:07 am

this might work for you.

Code: Select all

for /f "tokens=1-4 delims=/ " %a in ('date /t') do ren x.txt x.%d-%b-%c
lambda
Major General
 
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Website: http://www.hungry.com/~fn/
Location: Lahore


Return to “%s” Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron