AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

help renaming files

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
biotech



Joined: 24 Feb 2006
Posts: 145

PostPosted: Mon Jun 02, 2008 10:21 am    Post subject: help renaming files Reply with quote

i have a bunch of images with the filenames like this:
000001.tif
000002.tif
.
.
.
005466.tif
.
.
.
and so on...

is it possible to somehow get rid of leading zeroes in an simple and
effective way?

thanks in advance!
Back to top
View user's profile Send private message
BoBo²
Guest





PostPosted: Mon Jun 02, 2008 10:39 am    Post subject: Reply with quote

Code:
myPath := USERPROFILE . "\My Documents\My Pictures"
myExt := "tif"

Loop, %myPath%\*.%myExt %
{
   SplitPath, A_LoopFileName,,,OutExtension, OutNameNoExt
   ZeroUnpaddedFilename := OutNameNoExt / 1
   FileCopy, %A_LoopFileName%, %ZeroUnpaddedFilename%.%OutExtension%
   }
Question
Back to top
Hasso



Joined: 23 Mar 2005
Posts: 147
Location: Germany

PostPosted: Mon Jun 02, 2008 10:52 am    Post subject: Reply with quote

biotech,

open the folder with your files, mark the first file and press the hotkey (in my example Windows+dot):
Code:
#IfWinActive, ahk_class ExploreWClass
#.::
clipboard=
loop
  {
  Send, {F2}^c
  ClipWait
  If (clipboard=newname) ;break the loop at the last file name
    {
    send, {ESC}
    break
    }
  newname:=RegExReplace(clipboard, "^[0]+","") ;the "^" means that only leading zeros will be removed
  send, %newname%{ENTER}
  send, {DOWN}
  sleep, 200
  }
#IfWinActive
return


Tested.
_________________
Hasso

Programmers don't die, they GOSUB without RETURN
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group