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 

how to fill a string?

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



Joined: 06 Feb 2005
Posts: 8

PostPosted: Sun Feb 20, 2005 3:45 pm    Post subject: how to fill a string? Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
Invalid User



Joined: 14 Feb 2005
Posts: 442
Location: Texas, Usa

PostPosted: Sun Feb 20, 2005 3:50 pm    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Jon



Joined: 28 Apr 2004
Posts: 373

PostPosted: Sun Feb 20, 2005 4:13 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Yordan



Joined: 06 Feb 2005
Posts: 8

PostPosted: Sun Feb 20, 2005 5:21 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
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