Batch file 使用.bat脚本删除文件内容(注释除外)

Batch file 使用.bat脚本删除文件内容(注释除外),batch-file,cmd,batch-processing,Batch File,Cmd,Batch Processing,我有一个.properties文件,它的格式是 #### #These are the comments #### this is the content 我想删除除此文件注释以外的所有内容 findstr /b "#" "properties.properties" >new.properties 试试这个。我的理解正确吗?您想保留评论并删除内容吗?(很抱歉再次询问,但这似乎很不寻常)每条评论都从行的开头开始吗?是的,评论只在文件的开头,我可以说,开头的10行是评论,所以必须删除1

我有一个.properties文件,它的格式是

####
#These are the comments
####

this is the content
我想删除除此文件注释以外的所有内容

findstr /b "#" "properties.properties" >new.properties

试试这个。

我的理解正确吗?您想保留评论并删除内容吗?(很抱歉再次询问,但这似乎很不寻常)每条评论都从行的开头开始吗?是的,评论只在文件的开头,我可以说,开头的10行是评论,所以必须删除10行之后的所有内容。。。但是好的。Npcmaka的答案对您来说应该很好。答案对您有很大帮助,但我是否可以使用
properties.properties
only@viveksinghggits您可以在旧文件中添加一行移动
new.properties
move/y new.properties.properties
谢谢,是否有在线资源或您的博客,我可以在其中找到关于此的一些教程。不需要其他文件的技巧:
(对于/F“delims=“%%a in('findstr/B“#”properties.properties“^&del”properties.properties“)do echo%%a)>“properties.properties”