You can use the following Windows batch commands to delete files and shortcuts with specified names from a given directory in bulk:
@echo off
set "rootDir=C:\your\root\directory" //将 "C:\your\root\directory" 替换成您的目标根目录
set "fileName=newbie_guide.lnk" //将 "newbie_guide.lnk" 替换成您要删除的文件名
for /r "%rootDir%" %%f in (%fileName%) do (
del "%%f"
)
set "shortcutName=新手必读.lnk" //将 "新手必读.lnk" 替换成您要删除的快捷方式名
for /r "%rootDir%" %%s in (*%shortcutName%) do (
del "%%s"
)Description:
@echo offDo not display batch processing commands in the command line.set "rootDir=C:\your\root\directory"Store the path to the target root directory in a variable.rootDirMiddle.set "fileName=newbie_guide.lnk"The name of the file to be deleted is stored in a variable.fileNameMiddle.for /r "%rootDir%" %%f in (%fileName%) do (del "%%f"):make use offorIterate through all subdirectories within the specified directory to locate files with matching filenames and then use them.delIssue a command to delete them.set "shortcutName=新手必读.lnk"The name of the shortcut to be deleted is stored in a variable.shortcutNameMiddle.for /r "%rootDir%" %%s in (*%shortcutName%) do (del "%%s"):make use offorIterate through all subdirectories within the specified directory to find files whose shortcut name matches the given name, and then use them.delIssue a command to delete them.
Note: In Windows batch scripts, variable names must be enclosed in two percent signs (%).%%) is used to represent.