Sign in to follow this  
Followers 0
fxg4758

Select files to move and increase name

5 posts in this topic

#1 ·  Posted (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 by fxg4758

Share this post


Link to post
Share on other sites



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..."


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

?

;  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

Share this post


Link to post
Share on other sites

?

;  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

​Thanks a lot mikell !

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0