MyEarth Posted May 3, 2013 Share Posted May 3, 2013 Hello I'd like to do a task. I have ( or not have, depends on user select ) a number file list like: File_1.txt File_2.txt File_3.txt File_4.txt File_5.txt If a user delete a file, like: File_1.txt File_2.txt File_4.txt File_5.txt I want reneame the other file list, in this way File_1.txt File_2.txt File_3.txt (Previusly was File_4.txt) File_4.txt (Previusly was File_5.txt) I don't know how to check if file exist or not based on the number or file, then rename the rest of the list. Thanks Link to comment Share on other sites More sharing options...
jdelaney Posted May 3, 2013 Share Posted May 3, 2013 _FileListToArray You can have a loop, with a counter itterating in it, where you then FileMove($actualname, $newname) 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...
MyEarth Posted May 3, 2013 Author Share Posted May 3, 2013 (edited) I know i have to do an array and use FileMove ( i have read the guide about it before post ) but i want to reneame the files only if necessary ( 123567 4 is not here then reneame 567 to 456), not everytime. So i need to check if a number not exist or something like it, dunno Edited May 3, 2013 by MyEarth Link to comment Share on other sites More sharing options...
jdelaney Posted May 3, 2013 Share Posted May 3, 2013 #include <Array.au3> $dir = @DesktopDir & "\test\" $aFiles = _FileListToArray($dir) Local $aSortedNumerically[UBound($aFiles)-1][2] For $i = 1 To UBound($aFiles) - 1 $aSplit = StringSplit($aFiles[$i], "_") $aSortedNumerically[$i-1][0] = $aSplit[1] & "_" $aSortedNumerically[$i-1][1] = Int($aSplit[2]) Next _ArraySort($aSortedNumerically, 0,0,0,1) ;~ _ArrayDisplay($aSortedNumerically) $iCounter = 1 For $i = 0 To UBound($aSortedNumerically) - 1 ConsoleWrite($iCounter & " " & $aSortedNumerically[$i][1] & @CRLF) If $iCounter<>$aSortedNumerically[$i][1] Then FileMove($dir & $aSortedNumerically[$i][0] & $aSortedNumerically[$i][1] & ".txt", $dir & $aSortedNumerically[$i][0] & $iCounter & ".txt") EndIf $iCounter += 1 Next 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...
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