ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

File Renaming question

<< < (2/2)

Target:
this will do what you want (in AHK)


--- ---fileselectfolder, mypath, ::{20d04fe0-3aea-1069-a2d8-08002b30309d}

Loop, %mypath%\*.jpg
{
    stringtrimright, FName, a_loopfilename, 4
    fname:= floor(Fname - 1)
    Mylist.= a_loopfilefullpath . "~" . a_loopfiledir . "\" . fname . "`." . a_LoopFileExt . "`n"
}

sort, mylist, U

loop, parse, mylist, `n
{
    stringsplit, F2, a_loopfield, ~
    filemove, %F21%, %F22%, 1
}
exitapp

code loops through the nominated directory and creates a list of files.  it then sorts the list in ascending order (to avoid overwriting another file incorrectly), then moves the files to the new name

note that this very basic - it assumes all filenames are numeric (so alpha filenames may skew the results), and it won't start/stop at a given point (it will just plow through the whole directory)

anyways, it should give you an idea....

sajman99:
Thanks very much for the help. :)

AbteriX:
I just want to mention that ReNamer can do this too  :Thmbsup:

Here is an quick ReNamer script which will increase all numbers in an file name after an string:

     //Because some renamed names already exists, we will add an special sign '#' into the new name to get an unique name.
     //First rename the files with this PascalScript rule,
1. step)
File 7001.txt   File 7002#.txt
File 7002.txt   File 7003#.txt
File 7003.txt   File 7004#.txt
File 7004.txt   File 7005#.txt
File 7010.txt   File 7011#.txt
File 7100.txt   File 7101#.txt


    // then do an second run and
    //use an replace rule to remove that #-sign: Replace: Replace all "#" with "" (skip extension)
2. step)
File 7002#.txt   File 7002.txt
File 7003#.txt   File 7003.txt
File 7004#.txt   File 7004.txt
File 7005#.txt   File 7005.txt
File 7011#.txt   File 7011.txt
File 7101#.txt   File 7101.txt


--- End quote ---

--- Code: Text ---//PascalScript for den4b's ReNamer (http://www.den4b.com/projects.php), 2010 by Stefan//Purpose: Find number in file name and increase/decrease them.//This simple script works only for an file name pattern like://Name 7001.txt  => Name 7002.txt//Name 7025.txt  => Name 7026.txt//For more tasks the script has to be modified, if you have the need please visit the ReNamer forum at http://www.den4b.com/forum/ varSubPatterns: TStringsArray; Begin  SubPatterns:=SubMatchesRegEx(WideExtractBaseName(FileName),'(.+?)(\d+)',false);  if Length(SubPatterns) <=0 then exit;      //Because some renamed names already exists, we will add an special sign '#' into the new name to get an unique name.      //First rename the files with this PascalScript rule, then do an second run and    //use an replace rule to remove that #-sign: Replace: Replace all "#" with "" (skip extension)    FileName := SubPatterns[0] + IntToStr(StrToInt(SubPatterns[1]) + 1) + '#' + WideExtractFileExt(FileName); //increment  //FileName := SubPatterns[0] + IntToStr(StrToInt(SubPatterns[1]) - 1) + '#' + WideExtractFileExt(FileName); //decrementEnd.

sajman99:
Thanks for telling, AbteriX. ReNamer is my favorite file renaming utility, but there's clearly lots I don't know about it. Needless to say, Bulk Rename Utility really overwhelmed me with all its options.

MilesAhead:
Thanks for telling, AbteriX. ReNamer is my favorite file renaming utility, but there's clearly lots I don't know about it. Needless to say, Bulk Rename Utility really overwhelmed me with all its options.
-sajman99 (January 06, 2010, 12:35 PM)
--- End quote ---

BRU can be a killer.  Most of the time unless I want to perform concurrent operations I just use the rename utility built into FreeCommander.  It has a simple numbering feature and macros for name, count etc..  The main downer for FC is it's 32 bit Delphi code.  Runs fine on 32 OS but on Vista64 it can be sluggish.  Sometimes I click on a file and it takes a second or two to move the highlight.

Navigation

[0] Message Index

[*] Previous page

Go to full version