How to delete content from a text file using windows batch script

前端 未结 5 1988
星月不相逢
星月不相逢 2020-12-28 13:03

I have a demo.txt file. I need to delete content in that file using a batch file. Please tell me the command to delete content for demo.txt file.

5条回答
  •  渐次进展
    2020-12-28 13:19

    If the file is used by another application command prompt redirection may fail (as it requires more file access then necessary). In that case you can use powershell:

    PS> Set-Content file.txt $null
    

    Note: do not expect that it will allow access to exclusively opened files.

提交回复
热议问题