psgame_freak Posted March 26, 2007 Posted March 26, 2007 How can I do arithmetic keeping the zero's I entered in front of the number? What I want: 001 + 022 = 023 0050 * 0005 = 0250 What Autoit does: 001 + 022 = 23 0050 * 0005 = 250 I'm making a file renamer and Windows seems to think that 21 comes first before 1, so I need to make it 01 instead of just 1. Thank you in advance.
Xenobiologist Posted March 26, 2007 Posted March 26, 2007 HI, have a look at StringFormat. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
psgame_freak Posted March 26, 2007 Author Posted March 26, 2007 (edited) I used Formatstring as you suggested. I got my program to name each file accordingly except for the first file. It never renames the first file and I don't know why. Conditions for it to work: -folder is open in windows explorer -detailed view -first item highlighted expandcollapse popup$program_name = "renamer" If WinExists($program_name) Then MsgBox(0,"Alread Running!","Task is already running!") Exit EndIf AutoItWinSetTitle($program_name) HotKeySet("x","myexit") Func myexit() Exit EndFunc ;----------------------Script Below This Line------------------------ Global $start = "" Global $last = "" Global $windowname = "" setparam() Func setparam() $windowname = inputBox("Name of Window","Name of Window") $start = inputBox("Starting count","Starting count (eg 001)") $last = InputBox("Count till?","Count till (eg 010)") renamer() EndFunc Func renamer() Winactivate($windowname) Send("{DOWN}") Send("{UP}") $diff = $last - $start + 1 For $diff1 = $diff to 1 Step -1 $formattedstring = StringFormat("%03s",$start) Send("{F2}") Send("^{HOME}") Send("" & $formattedstring & "") Send(" ") Send("{ENTER}") Send("{DOWN}") $start = $start + 1 Next MsgBox(0,"Task Done!","Task Finished Successfully!") EndFunc ;----------------------Script Above This Line------------------------ Edited March 26, 2007 by psgame_freak
SadBunny Posted March 26, 2007 Posted March 26, 2007 This method of renaming works only if you have the right window open, and on top of that, you also NEED to have the right window layout. This is not so very useful, if you ask me. Maybe I misunderstand your goal, but wouldn't it be way more stable and easier to manage if you use FileMove? (It will also rename files.) This will work no matter what window a user has active, or what file is selected, or whatever. Will be much more stable and can be used with less preparation. If you want to rename a certain number of files or files that fit certain patterns, have a look at FileFindFirstFile, FileFindNextFile (for finding files in a folder), and FileListToArray (read file list into an array). Also check StringInStr() and/or StringRegExp() to search for specific patterns to test filenames for. Hope this helps. Roses are FF0000, violets are 0000FF... All my base are belong to you.
herewasplato Posted March 26, 2007 Posted March 26, 2007 (edited) ...I'm making a file renamer and Windows seems to think that 21 comes first before 1, so I need to make it 01 instead of just 1.Thank you in advance.You did not mention which Windows OS you are using, but you might want to take a look at the "intuitive filename sorting" option in Tweak UI for XP http://download.microsoft.com/download/f/c...wertoySetup.exeUsing "intuitive filename sorting" will make the Windows file explorer sort 5 before 21. Edited March 26, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
ReFran Posted March 26, 2007 Posted March 26, 2007 (edited) if you don't have the helpfile at hand (stringformat) you can make the result a decimal value and use stringright like: $x = 1 $y = $x * 0.001 msgbox(0,"",stringright($y,3)) HTH, Reinhard PS: "... will make the Windows file explorer sort 1 before 21." And I thought that would be standard. ;-) Edited March 26, 2007 by ReFran
herewasplato Posted March 26, 2007 Posted March 26, 2007 ...PS: "... will make the Windows file explorer sort 1 before 21." And I thought that would be standard. ;-)5 b4 21 :-) [size="1"][font="Arial"].[u].[/u][/font][/size]
psgame_freak Posted March 27, 2007 Author Posted March 27, 2007 (edited) Thank you very much for all the feedback guys. I will try them all ^.^ Me = newbie Edited March 27, 2007 by psgame_freak
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now