Batch file name modification with Excel and DOS commands

Source: Internet
Author: User
Tags command line

It's easy to change the file name in batches on your Windows computer. Select all the files, press F2, and then type the descriptive text.

Windows will add a unique sequence number to each file name.

This is a fairly quick solution, but not very flexible, because you can't customize the way you modify it.

For example, how do you add the current date to the filename? Or do you want to replace a few words or characters in the filename (such as a spelling error)? Or you want the file to be modified according to a different renaming system, such as file-a.jpg, rather than the default file (1). jpg.

To effectively bulk modify file names, you can learn some of the more complex Shell programming languages (Sed,awk,perl) or simpler, using only one spreadsheet and several DOS commands.

1: Click on the "Start" menu in the lower left corner of Windows, select "Run", enter cmd, return enter command line.

2: Use the CD command to enter the folder directory where you want to bulk modify the file name. Here, for example, I want to enter the Pics folder in C disk.

Cd

CD pics

3: Input dir/b You can see the list of all files under the current folder directory.

Enter dir/b > Pics.xls to output the list to the Pics.xls spreadsheet.

4: Interesting things just start now. Open Excel or Google Docs spreadsheet and you'll see the list of files in the first column.

5: In the next blank column, add a corresponding function formula-for example, use substitute to modify the characters specified in the file name, use CONCATENATE () and date () to add a date to the file name, and so on.

6: As shown above, select the + plus sign in the lower-right corner of the B1 cell and drag down so that our formula will be copied to all rows.

Now, your original filename is in column A, and you expect to replace the filename in column B--we're going to convert them into DOS now.

The rename command.

In column C, enter the Excel formula:

=concatenate ("Ren", A1, "", B1)

Click on the function's check mark, confirm the input is correct, drag to the lower right corner of the + Plus, apply to all lines.

7: Select the C column, click "Copy", in the C Disk Pics folder directory, create a Rename.bat file, paste the copied content.

8: Now we are basically finished. Under C:pics, enter the command Rename.bat and then enter, and you will find that the file name in the pics directory has been modified in the way you expected.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.