Tangwx

Tangwx

博客网站

bat Batch Create-Delete Files-Folders Modify Filenames Extensions

bat Batch Create/Delete Files/Folders Modify File Names Extensions#

1. Create/Delete Folders#

Command: md folder name you want to create or mkdir folder name you want to create

2. Create/Delete Files#

1. Create Empty Files#

Empty files mean that there is nothing inside the created file, it is an empty file.

Command: type nul>file name you want to create

Example: type nul>my video.txt
Created a file named my video.txt

2. Create Non-Empty Files#

Non-empty files have content written inside them when the command is executed.

Command: echo content you want to write into the file>file name you want to create

3. Delete Files#

Command: del file name you want to delete

3. Batch Change File Extensions#

Command: ren * .png *.jpg

If you want to change the extension of any file, replace the extension you want to modify with an asterisk (*). For example, to change the extension of all files to txt, use ren *.* *.txt.

4. Rename Files with a Regular Pattern and Prefix#

  1. Create a text file in the folder where you want to rename the files.
  2. Enter the following content:
@echo off
set a=0
setlocal EnableDelayedExpansion
for %%n in (*.jpg) do (
set /A a+=1
ren "%%n" "prefix content!a!suffix content.png"
)

Replace .jpg with the extension of the files you want to modify, and customize the prefix and suffix according to your needs. !a! represents a variable that increases from 0, and .png is the new extension after the modification.
3. Save the file and change the extension to .bat.
4. Double-click to execute and the modification will be successful.
This way, all jpg extensions will be changed to png, with a unified prefix of "image-", and the same applies to other files.

5. Custom Changes to Various Files#

By mastering the commands mentioned above and combining them with the functionality of Excel, you can quickly generate the files you want. The explanation of Excel is not covered here.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.