Tangwx

Tangwx

博客网站

Batch create-delete files-folders modify file names suffixes

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

1. Create/Delete Folders#

Command: md foldername or mkdir foldername

2. Create/Delete Files#

1. Create Empty File#

An empty file means that there is nothing inside the file, it is empty.

Command: type nul>filename

Example: type nul>myvideo.txt
Creates a file named myvideo.txt

2. Create Non-Empty File#

A non-empty file means that there is content inside the file.

Command: echo content>filename

3. Delete File#

Command: del filename

3. Batch Change File Extensions#

Command: ren *.oldextension *.newextension

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

4. Rename Files with a Regular Pattern and Prefix#

  1. Create a new 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!a!suffix.png"
)

Replace .jpg with the desired file extension to be renamed, and modify the prefix and suffix according to your needs. !a! represents a variable that increases from 0. .png is the new extension after renaming.
3. Save the file and change the extension to .bat
4. Double-click to execute and the renaming will be successful.
This way, all file extensions with .jpg will be changed to .png with a prefix of "prefix-", and the same can be done for other files.

5. Custom Changes to Various Files#

By combining the commands mentioned above with the functionality of Excel, you can quickly generate the files you want. The use of Excel is not explained here.

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