I. Pre-knowledge a and DirectoryInfo classes for batch renaming
Public instance methods used to create, move, and enumerate directories and subdirectories. This class cannot be inherited.
Use the DirectoryInfo class for typical operations, such as copying, moving, renaming, creating, and deleting directories.
If you want to reuse an object multiple times, consider using the instance method of DirectoryInfo, instead of the corresponding static method of the Directory class, because it is not always
Security check is required.
B, FileInfo
FileInfo. MoveTo moves the specified file to a new location and provides the option to specify a new file name.
In C #, when renaming a file, there is no rename function. The FileInfo. MoveTo method is used, and a new name is added to the original directory by MoveTo to rename the file.
FileInfo. MoveTo: moves the specified file to a new location and provides the option to specify a new file name. Therefore, it can be used to rename the file without changing the bit
Set );
DirectoryInfo. GetFiles (): gets the files in the directory (excluding subdirectories). The returned type is FileInfo []. Wildcards are supported;
C, Conbobox. Selectedxxxx
D, Path. Combine
Method -- combines 2-4 strings into a path
E, LastIndexOf
Int g = tests. LastIndexOf ("//", 5, tests. Length-5 );
Search from left to right of the tests string "//", returns the last
"//" Position in the string
Ii. Related
ReNameFile0.0.6.zip: add the original name and remove the first 10 digits (two names) and the Service website from the original name. Fix the wrong order of naming by character in the second order, increase the starting range of sequence number to 20
Iii. Related code
btn_rename_Click(.btn_rename.Visible = = idx = fix = (FileInfo fi di.GetFiles()) toFileName = .tb_fixed.Text + fi.MoveTo(Path.Combine(fi.DirectoryName, toFileName +++ btn_path_Click( (openFileDialogSearch.ShowDialog() === openFileDialogSearch.FileName; i = path.LastIndexOf( path = path.Substring(.btn_rename.Visible = Rename_Load( List<> moved = List<> ( i = ; i <= ; i++=.btn_rename.Visible = .Text =
Iv. program functions
Function: Name all files in the folder in a fixed format + number. Update the function: name all the files in the folder in a fixed format + the original name (used when there is a serial number before the original name)
1. Open the renamefile.exe program and run it.
2. Notes:
A. Select the first file under the folder you want to execute as the first file named, such as XXX0.txt.
B. If the file name is the same as the one you named, no
V. program download
Copy and paste the following address to the browser URL to download: (first version) http://files.cnblogs.com/hongmaju/ReName.zip (expired)
(Second Edition) http://files.cnblogs.com/hongmaju/Rename0.0.2.zip (expired)
(3) http://files.cnblogs.com/hongmaju/Rename0.0.3.zip (expired)
(Version 4) http://files.cnblogs.com/hongmaju/ReNameFile0.0.4.zip (expired)
(Fifth edition) http://files.cnblogs.com/hongmaju/ReNameFile0.0.5.zip (expired)
(Version 6) http://files.cnblogs.com/hongmaju/ReNameFile0.0.6.zip (expired)
(7) http://files.cnblogs.com/hongmaju/ReNameFile0.0.7.zip (normal download)
Article 7: http://www.cnblogs.com/hongmaju/p/3677974.html