 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
biotech
Joined: 24 Feb 2006 Posts: 145
|
Posted: Mon Jun 02, 2008 10:21 am Post subject: help renaming files |
|
|
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 |
|
 |
BoBo² Guest
|
Posted: Mon Jun 02, 2008 10:39 am Post subject: |
|
|
| 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%
} |  |
|
| Back to top |
|
 |
Hasso
Joined: 23 Mar 2005 Posts: 147 Location: Germany
|
Posted: Mon Jun 02, 2008 10:52 am Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|