AutoHotkey Community

It is currently May 25th, 2012, 5:16 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: how to fill a string?
PostPosted: February 20th, 2005, 3:45 pm 
Offline

Joined: February 6th, 2005, 11:33 pm
Posts: 8
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2005, 3:50 pm 
Offline

Joined: February 14th, 2005, 10:54 am
Posts: 447
Location: Texas, Usa
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 :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2005, 4:13 pm 
Offline

Joined: April 28th, 2004, 1:12 pm
Posts: 349
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=
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2005, 5:21 pm 
Offline

Joined: February 6th, 2005, 11:33 pm
Posts: 8
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


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Bing [Bot], BrandonHotkey, Cephei1, cmikaiti, SKAN, tomL, vinniel and 13 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