[英]How to Delete all contents of a “File with no extension” using windows batch Command
I want to delete the contents of a file which has "FIlE" as extension ie with no extension. 我想删除文件的内容,其中“FIlE”作为扩展名,即没有扩展名。 I know how to delete the contents of a Text file, but not about the file which has "File" as extension.
我知道如何删除文本文件的内容,但不知道如何删除“文件”作为扩展名的文件。
I would appreciate your efforts. 我很感激你的努力。 Thanks in advance.
提前致谢。
Use Del *.
使用
Del *.
in batch file to remove files with no extension. 在批处理文件中删除没有扩展名的文件。
use Dir /AD *.
使用
Dir /AD *.
to list down all files with no extension. 列出所有没有扩展名的文件。
Use following command to clear the contents of a file 使用以下命令清除文件的内容
findstr "Any data that is not available in origfilename" origfilename > origfilename
Try this: 试试这个:
echo. 2>file.
It will basically overwrite the file with nothing, achieving the same goal as removing all the contents. 它基本上会覆盖整个文件,实现与删除所有内容相同的目标。 Just replace
file.
只需替换
file.
with your file. 与您的文件。 To specify no extension just don't put anything after the
.
要指定没有扩展名,请不要在之后放置任何内容
.
Hope this helps. 希望这可以帮助。
copy nul YourFIlE
copy /y nul YourFIlE
In case you wonder, NUL
is a special name (like /dev/null
on UNIX), just as CON
(which is the console). 如果您想知道,
NUL
是一个特殊名称(如UNIX上的/dev/null
),就像CON
(它是控制台)一样。 I think this is the best way to clear the contents. 我认为这是清除内容的最佳方式。 The file will then have 0 bytes in it.
然后该文件将包含0个字节。 An
echo
plus output redirection will write one line to the file, so it does not completely clear the contents. echo
plus输出重定向将向文件写入一行,因此不会完全清除内容。
How about 怎么样
del /s "*."
Worked well on the tests I did on windows 10. Test it of course in a safe directory. 我在Windows 10上进行的测试工作得很好。当然在安全目录中测试它。 You can of course put this into a batch.
你当然可以把它放到批处理中。 I do one for cleaning out annoying left overs like .txt with something like:
我做了一个用于清理像.txt这样烦人的遗留问题,例如:
echo off
del /s D:\FILES\completed\*.nfo
del /s D:\FILES\completed\*.wflow
del /s D:\FILES\completed\*.workflow
del /s "D:\FILES\completed\*."
echo complete
echo on
Will delete all files in the main directory and all sub directories. 将删除主目录和所有子目录中的所有文件。
Quotes were required as it would not work without them. 需要引用,因为没有它们就行不通。 Did not try it with 3 deep extenstions.
没有尝试过3次深度扩展。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.