AutoHotkey Community

It is currently May 26th, 2012, 9:24 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: August 3rd, 2009, 3:28 am 
Offline

Joined: April 17th, 2007, 7:36 pm
Posts: 22
I've got a directory full of images that I need to rename. The current naming scheme is...

Slide1.gif
Slide2.gif
Slide3.gif
Slide4.gif
...
Slide30.gif

and I'd like to use AHK to rename them to...

001.gif
002.gif
003.gif
004.gif
...
030.gif

It is important that the slide numbers in the current set match the file numbers in the renamed files - these are slides exported from PowerPoint, so it is critical that they stay in the appropriate order.

Thanks,
Ryan


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2009, 4:03 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Should work fine for up to Slide99.gif
Code:
Directory = %A_Desktop% ; or whatever directory

Loop, %Directory%\*.gif
{   StringReplace, name, A_LoopFileName, Slide
   StringReplace, name, name, .gif
   FileCopy, % Directory "\" A_LoopFileName, % Directory (name<10 ? "\00" : "\0") name ".gif"
   FileDelete, % Directory "\" A_LoopFileName
}
Return

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2009, 4:20 am 
Offline

Joined: April 17th, 2007, 7:36 pm
Posts: 22
Brilliant! Thanks so much. I thought I was going to have to do this in PHP after I uploaded the file, but this is the better way. I really appreciate it.

_________________
---
I used AutoHotKey to write this signature crazy fast.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2009, 2:39 pm 
Offline

Joined: April 17th, 2007, 7:36 pm
Posts: 22
Quote:
Should work fine for up to Slide99.gif


How can I make it work up to Slide999.gif?

_________________
---
I used AutoHotKey to write this signature crazy fast.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2009, 2:46 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Code:
Directory = %A_Desktop% ; or whatever directory

Loop, %Directory%\*.gif
{   StringReplace, name, A_LoopFileName, Slide
   StringReplace, name, name, .gif
   FileCopy, % Directory "\" A_LoopFileName, % Directory (name<10 ? "\00" : (name<100 ? "\0" : "\")) name ".gif"
   FileDelete, % Directory "\" A_LoopFileName
}
Return

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 6th, 2009, 8:07 am 
I have a similar query please – I would like to rename a few files (these should not exceed more than 250 in total) that look like this –

Case Fragment_01_01Aug09_090304.xls
Case Fragment_02_01Aug09_112319.xls
Case Fragment_03_01Aug09_144221.xls
Case Fragment_04_01Aug09_185632.xls

Use AHK to rename them to -

Case Fragment_01_01Aug09.xls
Case Fragment_02_01Aug09.xls
Case Fragment_03_01Aug09.xls
Case Fragment_04_01Aug09.xls

In the above file names - Case Fragment_01_, Case Fragment_02_, Case Fragment_03_ etc. remains constant everyday. The file name is then followed by the current date and the current time when the file was generated, like for file number one it was at 09:03:04am and for file number four it was at 06:56:32pm and the date for all files being 01/Aug/2009.

Can I please have two codes to rename the files – one that will simply rename the files by stripping all the information after the date (basically the time value inserted in the file – as shown above) and another code that will also strip all the information after the date as done above but will rename the file depending on the current system date - that is – if I were to run it today to rename then the file names would –

Look like this -

Case Fragment_01_06Aug09.xls
Case Fragment_02_06Aug09.xls
Case Fragment_03_06Aug09.xls
Case Fragment_04_06Aug09.xls

From this -

Case Fragment_01_01Aug09_090304.xls
Case Fragment_02_01Aug09_112319.xls
Case Fragment_03_01Aug09_144221.xls
Case Fragment_04_01Aug09_185632.xls


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, wolverineks and 62 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group