| View previous topic :: View next topic |
| Author |
Message |
Yordan
Joined: 06 Feb 2005 Posts: 8
|
Posted: Sun Feb 20, 2005 3:45 pm Post subject: how to fill a string? |
|
|
hi guys!
how can in fill a string to a predetermined length with a character. for example, i have several filenames 1.txt, 73.txt, etc which should be changed into 001.txt, 073.txt, etc
any idea?
Yordan |
|
| Back to top |
|
 |
Invalid User
Joined: 14 Feb 2005 Posts: 442 Location: Texas, Usa
|
Posted: Sun Feb 20, 2005 3:50 pm Post subject: |
|
|
If String < 100
String = 0%String%
So on and so forth ya get the idea, I know i didnt explain this well at all,
and this is assuming all the file names are numbers
if not you could use StringLen to find out how many chars are in the string and all them based on that result _________________ my lame sig  |
|
| Back to top |
|
 |
Jon
Joined: 28 Apr 2004 Posts: 373
|
Posted: Sun Feb 20, 2005 4:13 pm Post subject: |
|
|
Here is another way of doing it-
| Code: |
Loop, %a_workingdir%\*.txt
{
SplitPath, A_LoopFileFullPath, OutFileName
StringLen, Length, OutFileName
Number:= 7 - Length
loop, %Number%
{
toadd=0%toadd%
}
newname=%toadd%%OutFileName%
FileCreateDir, %A_workingdir%\renamed\
FileCopy, %A_LoopFileFullPath%, %A_workingdir%\renamed\%newname%
toadd=
} |
|
|
| Back to top |
|
 |
Yordan
Joined: 06 Feb 2005 Posts: 8
|
Posted: Sun Feb 20, 2005 5:21 pm Post subject: |
|
|
i found another way for this special case (filename is number, fill with zeros):
SetFormat, float, 03.0
SelectedFilename += 0.0
anyway thanks for your tips!
Yordan |
|
| Back to top |
|
 |
|