Swiss File Knife
a command line
free external tools,
- download the free Swiss File Knife Base from Sourceforge. - open the Windows CMD command line, Mac OS X Terminal or Linux shell. - OS X : type mv sfk-mac-i686.exe sfk and chmod +x sfk then ./sfk - Linux: type mv sfk-linux.exe sfk and chmod +x sfk then ./sfk OS X and Linux syntax may differ, check the help within the tool.
sfk rename dirname "/fromtext/totext/" [to outdir] sfk rename -dir mydir -file .txt -pat "/fromtext/totext/" flexible multi file rename using rename expressions. handle with care. - multi file rename may cause problems in folders which are controlled by version control systems like cvs or svn, or within workspaces of programs that keep file references, like video editing software or IDE's. - keep backups of original files in case that output filenames are unexpected or cause conflicts. to make things more safe, by default - sfk rename runs on the given folder only, without sub folders. use option -withsub to include sub folders. - sfk rename runs in simulation mode, previewing changes without modifying anything. add option -yes to apply changes. syntax of /fromtext/totext/ rename expressions are a subset of simple expressions, supporting an extra symbol '#' within totext. slash patterns are not enabled by default but require an option -spat. instead of "/" around /from/to/ any unique char can be used, like in _fromtext_totext_ within /fromtext/ you may use: * for any number of chars (0 or more) ? for exactly one character [n chars] for exactly n characters within /totext/ you may use: [part1] fill in part 1 extracted from name [parts 1,3] fill in parts 1 and 3 [parts 1-3] fill in parts 1 to 3 #1 fill in part 1, same as [part1] #10 fill in part 10 # without digits: fill in next part #5## fill in parts 5,6,7 with option -spat only: \[ search or fill in the '[' character \] \# * \? same for characters ] # * ? \\ search or fill in the backslash '\' extra parameters to outdir after rename, move the file to folder outdir which must be on the same partition. options -pat x to specify /from/to/ pattern after long -dir ... -file ... parameters -spat enable slash patterns like \xnn must be given before or after pattern -exact fromtext must match whole filename, not just a part of it. -verbose show part numbers within /from/ text -quiet do not show changed names -[no]stat show statistics or not accent or umlaut characters in the search pattern may have to be rewritten by wildcard "?" to match. quoted multi line parameters are supported in scripts using full trim. type "sfk script" for details. aliases sfk rensub same as "sfk rename -withsub" beware of Shell Command Characters. to find or replace text patterns containing spaces or special characters like <>|!&?* you must add quotes "" around parameters or the shell environment will destroy your command. for example, pattern /foo bar/other/ must be written like "/foo bar/other/" within a .bat or .cmd file the percent % must be escaped like %% even within quotes: sfk echo -spat "percent %% is a percent \x25" about example numbers with [brackets] if you see  type "sfk cmd 1" for whole command in one line. web reference http://stahlworks.com/sfk-rename more in the SFK Book the SFK Book contains a 60 page tutorial, including rename examples with input and output filenames. type "sfk book" for details. see also sfk xrename rename files and folder names using full SFK Expressions and many patterns. sfk renfile rename just a single file sfk rendir rename just a single folder examples: short syntax step by step sfk rename mydir list all files of mydir (nothing is changed) sfk ren mydir "/-1540-*.mts/" list files in mydir with "-1540-" in their filename, followed by any characters, until .mts. sfk will show an info text telling about the part numbers the search mask (fromtext) is made of. sfk ren mydir "/-1540-*.mts/[part1]News[part3]/" same as above, but extended to change the wild- card part "*" of a match to "News". sfk ren mydir "/-1540-*.mts/#News#3/" same as above, but shorter to type. "#" without a number takes part1, #3 takes part 3. sfk ren mydir "/-1540-*.mts/#News#3/" to news after rename move the file to folder "news". finally add -yes to apply filename changes. examples: flexible syntax step by step sfk rename -dir mydir -file chan list files of mydir having "chan" in their name sfk ren -dir mydir -file chan -pat "/-1540-*.mts/" list chan files in mydir with "-1540-" in their filename, followed by any characters, until .mts sfk ren -dir mydir -file chan -pat "/-1540-*.mts/#News#3/" within filenames of mydir containing parts -1540-, then anything, then .mts, like in: Channel3-01312015-1540-BizInfo_Any.mts change the second part "*" into "News": Channel3-01312015-1540-News.mts further examples sfk rename . /.mts/.mpg/ change all .mts to .mpg in current folder sfk rename mydir -spat "/\xE4/ae/" change special character with code 0xE4 to ae. use sfk xrename to supply many of such patterns. sfk ren -dir mydir -file .txt -pat "/foo/bar/" replace foo by bar in all .txt filenames within mydir sfk ren -dir mydir -file "*-????2015-" -pat "/-[2 chars][2 chars][4 chars]-[4 chars]-*. /-[parts 4,2,3]-[parts 6-9]/" in folder mydir change date string in files like:  Channel3-01312015-1540-BizInfo_Any.mts to a format with year first: Channel3-20150131-1540-BizInfo_Any.mts sfk ren -dir mydir -file "*-????2015-" -pat "/-[2 chars][2 chars][4 chars]-[4 chars]-*. /-#4#2#-#6###/" same as above, only shorter. #6### means to take part 6 and then the three following parts 7,8,9. 
sfk is a free open-source tool, running instantly without installation efforts. no DLL's,
no registry changes - just get sfk.exe from the zip package and use it (binaries for
windows, linux and mac are included).
read more about all sfk functions here.