IanN1990 Posted August 7, 2012 Share Posted August 7, 2012 (edited) Hey, I have a big folder for tri-screen wallpers but its has sooo many pictures and over time i deleted alot. Which has lead to bad numbering. Ie 300, 311, 312, 313 etc. I wanted to use autoit to rename it all for me but i seam to hit a problem when it does the numbering like 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 21, etc How can i fix this ? $search = FileFindFirstFile("*.jpg*") local $i = 0 local $file If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop FileMove($file, $i & ".jpg") $i = $i + 1 WEnd FileClose($search) Edited September 8, 2012 by IanN1990 Link to comment Share on other sites More sharing options...
jdelaney Posted August 7, 2012 Share Posted August 7, 2012 (edited) from what i'm reading, it apperas that FileFindFirstFile, and nextfile, sort by alpha, not integer...so if you get the file list, and sort it as an integer, then loop through that, to rename the files, you should be fine...let me know if that's not the case...here is how to sort by integer: #include <Array.au3> #include <File.au3> $array = _FileListToArray ( "path", "*.jpg", 1 ) ; use this to populate the array dim $array[5]=[0,"1.jpg", "5.jpg", "3.jpg","8.jpg"] ; this is just for debugging For $i = 1 to UBound ( $array ) - 1 $array[$i] = Int($array[$i]) Next _ArraySort($array) _ArrayDisplay($array) ; Then loop through the above array, and append a .jpg to the end, to find the file and rename it. edit: simplified to only use Int...no need to remove .jpg Edited August 7, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
IanN1990 Posted August 7, 2012 Author Share Posted August 7, 2012 (edited) Works a treat thanks Ur code might also be able to help me fix a problem in my context menu as well, kinda funny how one soluation could fix another. Edited August 7, 2012 by IanN1990 Link to comment Share on other sites More sharing options...
AZJIO Posted August 7, 2012 Share Posted August 7, 2012 $test= _ '1' & @CRLF & _ '11' & @CRLF & _ '111' & @CRLF & _ '12' & @CRLF & _ '2' & @CRLF & _ '21' & @CRLF & _ '22' & @CRLF & _ '3' MsgBox(0, "-", $test) $test=StringRegExpReplace($test, '(d+)', '0000000000001') $test=StringRegExpReplace($test, '.*(d{4})', '00001') MsgBox(0, "Yes", $test)On the "RegEx" tab to execute replacement1. '(d+)' -> '0000000000001'2. '.*(d{4})' -> '00001'On the "Generation" tab to create new numbers. My other projects or all Link to comment Share on other sites More sharing options...
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