p> 或者,我想您可能想要以下内容: del%1 \ *%2.js 您会这样称呼: tmp.bat文件夹名称1.1.1.0 您可能还希望传递'/ F'标志以删除,以确保它删除了只读文件... 如果您也想在子目录中执行文件,则批处理文件应如下所示: echo del / f / s%1\ *%2.js 再次,其中%1是要开始的文件夹名称,%2是要删除的数字... 要执行所有操作但要给定数字,您可以执行以下操作: attrib + h *%1.js del / q * attrib -h *%1.js 到从给定的文件夹中删除所有但给定编号的东西,您可以这样做: pushd%1 attrib + h *%2.js del / q * attrib -h *%2.js popd 其中%1是文件夹,%2是数字 I am looking to write a batch file that will remove all files from a directory where there file name ends in a particular number.Eg delete all files of type .js from a folder where the filename end in 1.1.1.0Any tips as to how I may write such a batch file to achieve this?How would it be different if I wanted to delete all of the files of type .js that didn't end in 1.1.1.0? 解决方案 So, it seems you could just do:del *1.1.1.0.jsOr, you could write a batch file (tmp.bat) like this:del *%1.jsAnd call it:tmp.bat 1.1.1.0But that seems like overkill?Is there something I'm missing?Or, I guess you might want something like:del %1\*%2.jsWhich you would call as:tmp.bat folderName 1.1.1.0You may also want to pass a '/F' flag to delete, to make sure it deletes readonly files...If you wanted to do files in subdirectories as well, the batch file could look like this:echo del /f /s %1\*%2.jsAgain, where %1 is the folder name to start from and %2 is the number you want to delete...To do everything BUT a given number, you could do something like this:attrib +h *%1.jsdel /q *attrib -h *%1.jsTo delete everything BUT a given number, from a given folder you could do this:pushd %1attrib +h *%2.jsdel /q *attrib -h *%2.jspopdWhere %1 is the folder and %2 is the number 这篇关于批处理文件以删除文件名以特定字符结尾的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!