Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用If not命令制作批处理文件,例如:IF NOT [extension type] Then delete all在文件夹中?
If not
IF NOT [extension type] Then delete all
该for命令结合if命令和变量扩展可用于删除除具有指定扩展名的文件之外的所有文件。例如,这将删除当前目录中没有 .TXT 扩展名的所有文件(不区分大小写):
for
if
for %%i in (*) do ( if /i "%%~xi" neq ".TXT" del %%i )