fxg4758 Posted April 24, 2015 Share Posted April 24, 2015 (edited) Hi. I want to search files between two values and increase the names of files. For example: Search files with name between 15 and 22 and increase 15 to 16 and 22 to 23 or decrease files 15 to 14 and 22 to 21. Regards. 10.txt 11.txt 15.txt 22.txt $Start = GUICtrlRead($txtStart) $End = GUICtrlRead($txtEnd) $FilePath = GUICtrlRead($file) $FileExt = _Iif(GUICtrlRead($txtExt) = "", "*", '"*.' & GUICtrlRead($txtExt) & '"') $list = _FileListToArray($FilePath,$FileExt) _ArraySort(list, 1) For $x = 1 to $list[0] If $list[$x] >= $Start And $list[$x] <= $End Then Local $in = $FilePath & "\" & $list[$x] Local $out = String($list[$x] + 1) If $out < 10 then $out = "0" & $out FileMove($in, $FilePath & "\" & $out,1) EndIf Next Edited April 24, 2015 by fxg4758 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 24, 2015 Moderators Share Posted April 24, 2015 First off, this is obviously an old script (or you're on an old version of AutoIt) since _Iif has been deprecated for some time. Secondly, can you please post runnable code, or explain in detail what you're looking to do? Saying you want to "increase name of files" doesn't make a lot of sense (there may be a language barrier). Your best bet would be to post the entire code, along with a concise explanation of what you want to do. Something like: "If the value in textbox 1 = the value in textbox 2 I want the script to do this..." -or- "If the value in textbox 1 is blank I want to use the value in textbox 2 and do this..." "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
fxg4758 Posted April 24, 2015 Author Share Posted April 24, 2015 First off, this is obviously an old script (or you're on an old version of AutoIt) since _Iif has been deprecated for some time. Secondly, can you please post runnable code, or explain in detail what you're looking to do? Saying you want to "increase name of files" doesn't make a lot of sense (there may be a language barrier). Your best bet would be to post the entire code, along with a concise explanation of what you want to do. Something like: "If the value in textbox 1 = the value in textbox 2 I want the script to do this..." -or- "If the value in textbox 1 is blank I want to use the value in textbox 2 and do this..." Hi. I have changed the post to i want to do with the code. Regards. Link to comment Share on other sites More sharing options...
mikell Posted April 25, 2015 Share Posted April 25, 2015 ? ; 8.txt => 09.txt ; 08.txt => 09.txt ; 15.txt => 16.txt #include <File.au3> $FilePath = @scriptdir $ext = ".txt" $list = _FileListToArray($FilePath, "*" & $ext) For $i = 1 to $list[0] $s = StringSplit($list[$i], ".") $n = Number($s[1]) If $n > 5 and $n < 18 Then $k = StringFormat("%02i", $n+1) FileMove($list[$i], $FilePath & "\" & $k & $ext, 1) ; overwrite Endif Next You might get some trouble if exist 2 different files named "8.txt" and "08.txt" otherwise this should work Link to comment Share on other sites More sharing options...
fxg4758 Posted April 26, 2015 Author Share Posted April 26, 2015 ?; 8.txt => 09.txt ; 08.txt => 09.txt ; 15.txt => 16.txt #include <File.au3> $FilePath = @scriptdir $ext = ".txt" $list = _FileListToArray($FilePath, "*" & $ext) For $i = 1 to $list[0] $s = StringSplit($list[$i], ".") $n = Number($s[1]) If $n > 5 and $n < 18 Then $k = StringFormat("%02i", $n+1) FileMove($list[$i], $FilePath & "\" & $k & $ext, 1) ; overwrite Endif Next You might get some trouble if exist 2 different files named "8.txt" and "08.txt" otherwise this should workThanks a lot mikell ! 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