Download the test version:
Http://www.symental.com/sfw/xrename.zip
Xrename, also known as the file folder super rename tool, can help you quickly rename a batch of files or folders according to the specified requirements, for example, replace "volume" in the file names of all files in the specified directory with "volume ". The biggest feature of this tool is that it allows advanced users to use regular expressions to set their own rules. The scope of the file to be processed can also be limited by regular expressions, which is basically omnipotent. The following describes the xrename command and usage.
Level 2 commands
1. Replace the characters in the file name with the following syntax:
Replace-Dir directory-string string1-(New | newstring | replacewith) string2 [-type (File | dir | all) [: string3] [-subdir (Yes | no)] [-ignorecase (Yes | no)] [-log (Yes | no)]
Function Description: Replace the characters in the names of files or folders in a directory with the specified rules. regexp1 and regexp2 indicate that regular expressions can be used.
Parameter description:
Double quotation marks are recommended for specific parameter values, because if the parameter value contains spaces, it will affect the program's judgment. Except for regular expressions, because it is already expressed in.
-DirYou can also write-path to the directory to be processed.
-StringThe string to be replaced. Here, we can use a regular expression in the format of "/Regexp/IMG", which is the same as the setting in the JS script. Note that it cannot be added with double quotation marks. Otherwise, it will only be treated as a normal string. The matching attribute of the regular expression can be controlled after the second or later. I is used for case-insensitive matching, M is used for multi-row matching, and G is used for all matching items. Because the file name does not have line breaks, therefore, adding m without M is redundant. By default, the matching attribute of a regular expression is "case sensitive" and "non-global matching ".
-NewAfter replacement, you can also write-newstring and-replacewith. If the previous-string uses the regular expression, the content can be captured in groups such as "$1" or "$2". Otherwise, the content will only be processed as a normal string.
-TypeThe type of the object to be processed. There are three cases. That is, file, Dir, and all ). The default value is file, that is, only the file is processed. You can add ":" To this parameter and specify the processing range. Here, you can use regular expressions or common characters. If a common character is a fixed string or a matching string, it is compatible with the Windows matching method. For example, *. txt is used to process all TXT files ,? Represents a single character. If you want to use a regular expression, the requirements are the same as those for the-string parameter to use a regular expression.
-SubdirWhether sub-directories need to be processed. Yes indicates processing, and recursively accesses sub-directories. No indicates that sub-directories are not processed. The default value is no, indicating that only all files or folders in the current folder are processed.
-IgnorecaseWhether to ignore uppercase/lowercase letters. Yes is ignored, that is, it is case-insensitive and no is case-insensitive. The default value is yes, which is used when-string uses a normal string. If a regular expression is used, it is determined by the I mark after.
-LogWhether to output processing logs. The file name is xrename. log. Yes indicates output, but no indicates no output. The default value is no, indicating that log files are not produced. In addition, if an error occurs during xrename processing, a file named xrename_err.log is generated no matter whether-log is specified or not.
Example:
(1) Replace "friends" in the names of all files under "C: \ movie \" with "friends"
Xrename replace-Dir "C: \ movie \"-string "friends"-replacewith "friends"
(2) Replace the spaces in the file names of all files under "C: \ movie \" with underscores and generate a log
Xrename replace-Dir "C: \ movie \"-string ""-replacewith "_"-log Yes
(3) Replace all files suffixed with WMA with rmvb suffix names under "C: \ movie.
Xrename replace-Dir "C: \ movie \"-string "WMA"-replacewith "rmvb"
The above method may not be safe, because it must be replaced by WMA at the end. You can use a regular expression for exact processing:
Xrename replace-Dir "C: \ movie \"-string /(.*?) WMA $/Ig-replacewith "$1 rmvb"Or:
Xrename replace-Dir "C: \ movie \"-string/WMA $/Ig-replacewith "rmvb"
If you need to further narrow down the scope and specify to process WMA files, use the following method:
Xrename replace-Dir "C: \ movie \"-string/WMA $/Ig-replacewith "rmvb"-type file: "*. wma"Or
Xrename replace-Dir "C: \ movie \"-string/WMA $/Ig-replacewith "rmvb"-type file:/. * \. wma/ig
2. Delete characters in the file name. Syntax:
Delete-Dir directory-string string1 [-type (File | dir | all) [: string3] [-subdir (Yes | no)] [-ignorecase (Yes | no)] [-log (Yes | no)]
Function Description: Delete the characters in the names of files or folders in a directory according to the specified rules. This command can be replaced by the replace command, that is, replaced with null.
Parameter description: refer to the parameter description section of the replace function.
Example:
(1) Delete "book" from all file names under "C: \ movie \"
Xrename Delete-Dir "C: \ movie \"-string "book"
(2) Delete "[" and "]" from all file names under "C: \ Inet \". This application is very typical, for example, files copied from the temporary ie folder will basically contain the characters [1] and [2 ].
Xrename Delete-Dir "C: \ Inet \"-string/\ [| \]/ig
If you want to delete [1] or [2] directly, you can use the following method, but it may cause a conflict.
Xrename Delete-Dir "C: \ Inet \"-string/\ [\ D + \]/ig
3. list file names. Syntax:
Listfile-Dir directory-string string1 [-type (File | dir | all) [: string3] [-subdir (Yes | no)] [-ignorecase (Yes | no)] [-output path]
Function Description: export the name list of files or folders that comply with the specified rules in a directory.
Parameter description: refer to the parameter description section of the replace function. In this example, -outputindicates the stored snapshot, and specifies the xrename_list.txt file in the directory.
Example:
(1) list all files under "C: \ movie \" whose names contain "classic"
Xrename listfile-Dir "C: \ movie \"-string "classic"
(2) list all files whose names start with "classic" and end with CD1 (excluding suffix names) under "C: \ movie, export the content to "C: \ classicmovie.txt"
Xrename listfile-Dir "C: \ movie \"-string/^ classic. ++? CD1 (\. [^ \.] *)? /Ig-output "C: \ classicmovie.txt"
4. delete an object. Syntax:
Delfile-Dir directory-string string1 [-type (File | dir | all) [: string3] [-subdir (Yes | no)] [-ignorecase (Yes | no)] [-log (Yes | no)]
Function Description: delete files or folders under a directory that meet the specified rules.
Parameter description: refer to the parameter description section of the replace function.
Example:
(1) Delete all files whose names contain "cangjing Kong" under "C: \ movie \"
Xrename delfile-Dir "C: \ movie \"-string "Aoi"
(2) Delete all directories named numbers under "C: \ test \", including subdirectories. Subdir indicates whether the Sub-directory is included.
Xrename delfile-Dir "C: \ test \"-string "^ \ D + $"-type Dir-subdir Yes
5. UTF-8 decoding. Syntax:
Utf8rename-Dir directory [-type (File | dir | all) [: string3] [-subdir (Yes | no)] [-ignorecase (Yes | no)] [-log (Yes | no)]
Function Description: decode the file name using utf8 encoding. It is mainly used to rename the file copied from the temporary ie folder.
Example:
Xrename utf8rename-Dir "C: \ movie \"
6. other items to be supplemented.
Note:
By default, the characters After-string are actually used as regular expressions. Therefore, some characters (metacharacters of regular expressions, that is, key characters) need to be escaped, assume that "Replace with"-"because the two characters indicate special meanings in the regular expression. If you want to replace the two characters, it means". ", you need to write it "\. "To escape, this is actually the knowledge of regular expressions. Another note is that all parameters must be enclosed by double quotation marks. But what should you do if the character you want to replace contains double quotation marks? The scheme in xrename is to use \ escape. For example, to delete double quotation marks from a file name, use xrename Delete-Dir
"C: \ movie \"-string "\""
Sysdzw
2011-10-13
Note:
2011-3-31 has a function to be modified:
'Get the content used for regular expression matching and store it in an array
Private function reggetstrsubs (strdata $, strpattern $)
Dim S $, V, I %
Reg. pattern = strpattern
Set matchs = reg. Execute (strdata $)
If matchs. Count> = 1 then
For I = 0 to matchs (0). submatches. Count-1
S = S & matchs (0). submatches (I) & vbcrlf
Next
End if
If S <> "" then
S = left (S, Len (S)-2)
Else
S = "* null *"
End if
Reggetstrsubs = Split (S, vbcrlf)
End Function
Update
* Supports reverse encoding of utf8 file names. Xrename utf8rename can be processed.
* Supports reference of relative directories. If it is used in batch processing, the-Dir parameter is omitted to indicate the current directory where BAT is processed.
Delete [1]