如何从目录中删除所有文本文件通过批处理文件接受一个? [英] How to delete all text file from a directory accept one through batch file?

查看:84
本文介绍了如何从目录中删除所有文本文件通过批处理文件接受一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个目录中删除所有文本文件,接受一个文本文件.该目录包含其他文件以及文本文件.例如,在目录中,有4个不同的文件:

I want to delete the all the text file from a directory accept one text file.That directory contains other file along with text file. For Example In directory there are 4 different file:

D:\
a.txt   b.txt   test.c    test1.cpp

我要删除所有接受a.txt的文本文件,因此目录包含以下文件:

I want to delete all the text file accept a.txt,Hence directory contain following file:

a.txt     test.c     test1.cpp

考虑a.txt在该目录中始终可用,但其他文件中不可用

Consider that a.txt will always available in that directory but not other files

推荐答案

以下操作将删除当前目录中除A.TXT之外的所有*.TXT文件:

Following will remove all *.TXT files in current directory except A.TXT:

FOR %%t IN (*.TXT) DO IF /I NOT "%%~nt" == "a" DEL "%%t"

这篇关于如何从目录中删除所有文本文件通过批处理文件接受一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆