Batch rename files under Windows [bat implementation]

Table of contents

foreword

1. Windows simply implements renaming

Second, use the command line and Excel to achieve renaming


foreword

在实际应用中,我们经常会遇到将指定文件夹下的文件重命名,以便程序读写。

This article introduces two methods, both of which are renaming methods that come with the Windows system.


1. Windows simply implements renaming

Step 1: Enter the folder that needs to be renamed, select all the files that need to be renamed [Ctrl+A]

Step 2: Click the right mouse button, select Rename [M], and input the desired file name, for example, I input [File]

Step 3: Get the renamed file. As shown in the figure below, this method gets the result of the input file name + (number)


Second, use the command line and Excel to achieve renaming

In the first method, only the default renaming result can be obtained. If you need to modify a certain file to a specific file name among a large number of files, you can use the following method. This method is more practical.

Step 1: Enter the folder to be renamed, open the command line [cmd], and enter the command

dir/b>rename.csv
#  >这个符号是将dir命令的输出写入后面提供的文件中,所以上述命令会得到一个文件rename.csv文件

  Step 2: Open the rename.csv file. You can see that the first column is all the file names under our current folder, and then enter each name that needs to be renamed in the second column. Note that each row is a one-to-one correspondence

 

  Step 3: Enter the formula [="ren "&""""&A1&""""&" "&B1] in the third column to generate a rename string 

renIt is the abbreviation of rename.
Note: When connecting cells, if the cell has special symbols, double quotation marks need to be added ( that is, four double quotation marks need to be entered ). There is no need to add double quotation marks if there are no special characters.

  Step 4: Copy the content of the third column to the newly created txt file in the current folder, and rename it as a bat file

  Step 5: Double-click to run the bat file to get the renamed file

Guess you like

Origin blog.csdn.net/Gary_ghw/article/details/130387038