【问题标题】:deleting content of a file excepting comments using .bat script使用 .bat 脚本删除文件的内容(注释除外)
【发布时间】:2016-05-23 08:42:22
【问题描述】:

我有一个格式为 .properties 的文件

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

this is the content

我想删除除此文件的 cmets 之外的所有内容。

【问题讨论】:

  • 我理解正确吗?您想保留 cmets 并删除内容吗? (很抱歉回问,但这似乎很不寻常)是否每条评论都从行首开始?
  • 是的,cmets 只是在文件的开头,我可以说,开头的 10 行是 cmets,所以必须删除 10 行之后的所有内容
  • 奇怪...但没关系。 Npocmaka 的回答应该适合你。

标签: batch-file cmd batch-processing


【解决方案1】:
findstr /b "#" "properties.properties" >new.properties

试试这个。

【讨论】:

  • answer 有很大帮助,但有没有办法只使用 properties.properties 来做到这一点
  • @viveksinghggits 您可以添加将new.properties 移动到旧文件的行:move /y new.properties properties.properties
  • 谢谢,有没有在线资源或者你的博客在哪里可以找到这方面的教程。
  • 不需要其他文件的技巧:(for /F "delims=" %%a in ('findstr /B "#" "properties.properties" ^& del "properties.properties"') do echo %%a) >> "properties.properties"
猜你喜欢
  • 2018-01-22
  • 2015-03-04
  • 1970-01-01
  • 2012-05-16
  • 1970-01-01
  • 2016-02-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多