【问题标题】:Creating long text file in cmd在cmd中创建长文本文件
【发布时间】:2013-05-12 13:01:47
【问题描述】:

简单的问题,我需要用批处理文件创建 reset.css 文件。我知道如何制作短文本文件,但是当尝试输入长文本时它不起作用。

这是正文

    html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}

我只需要一些命令,以便我可以将此文本粘贴到批处理文件中以便保存

【问题讨论】:

    标签: file text cmd


    【解决方案1】:

    这与另一个答案中的代码相同,但进行了更改以允许更轻松的编辑和正确的文件名。

    @echo off
    set "file=reset.css"
    >>%file% echo     html, body, div, span, applet, object, iframe,
    >>%file% echo h1, h2, h3, h4, h5, h6, p, blockquote, pre,
    >>%file% echo a, abbr, acronym, address, big, cite, code,
    >>%file% echo del, dfn, em, img, ins, kbd, q, s, samp,
    >>%file% echo small, strike, strong, sub, sup, tt, var,
    >>%file% echo b, u, i, center,
    >>%file% echo dl, dt, dd, ol, ul, li,
    >>%file% echo fieldset, form, label, legend,
    >>%file% echo table, caption, tbody, tfoot, thead, tr, th, td,
    >>%file% echo article, aside, canvas, details, embed, 
    >>%file% echo figure, figcaption, footer, header, hgroup, 
    >>%file% echo menu, nav, output, ruby, section, summary,
    >>%file% echo time, mark, audio, video {
    >>%file% echo     margin: 0;
    >>%file% echo     padding: 0;
    >>%file% echo     border: 0;
    >>%file% echo     font-size: 100%%;
    >>%file% echo     font: inherit;
    >>%file% echo     vertical-align: baseline;
    >>%file% echo }
    >>%file% echo /* HTML5 display-role reset for older browsers */
    >>%file% echo article, aside, details, figcaption, figure, 
    >>%file% echo footer, header, hgroup, menu, nav, section {
    >>%file% echo     display: block;
    >>%file% echo }
    >>%file% echo body {
    >>%file% echo     line-height: 1;
    >>%file% echo }
    >>%file% echo ol, ul {
    >>%file% echo     list-style: none;
    >>%file% echo }
    >>%file% echo blockquote, q {
    >>%file% echo     quotes: none;
    >>%file% echo }
    >>%file% echo blockquote:before, blockquote:after,
    >>%file% echo q:before, q:after {
    >>%file% echo     content: '';
    >>%file% echo     content: none;
    >>%file% echo }
    >>%file% echo table {
    >>%file% echo     border-collapse: collapse;
    >>%file% echo     border-spacing: 0;
    >>%file% echo }
    

    【讨论】:

      【解决方案2】:

      您需要转义特殊字符并可能使用引号! :)

      这是我使用 TextZipper 得到的结果...

      @echo off
      echo Textzipper is writing the files...
      echo     html, body, div, span, applet, object, iframe, >> "asd.txt"
      echo h1, h2, h3, h4, h5, h6, p, blockquote, pre, >> "asd.txt"
      echo a, abbr, acronym, address, big, cite, code, >> "asd.txt"
      echo del, dfn, em, img, ins, kbd, q, s, samp, >> "asd.txt"
      echo small, strike, strong, sub, sup, tt, var, >> "asd.txt"
      echo b, u, i, center, >> "asd.txt"
      echo dl, dt, dd, ol, ul, li, >> "asd.txt"
      echo fieldset, form, label, legend, >> "asd.txt"
      echo table, caption, tbody, tfoot, thead, tr, th, td, >> "asd.txt"
      echo article, aside, canvas, details, embed,  >> "asd.txt"
      echo figure, figcaption, footer, header, hgroup,  >> "asd.txt"
      echo menu, nav, output, ruby, section, summary, >> "asd.txt"
      echo time, mark, audio, video { >> "asd.txt"
      echo     margin: 0; >> "asd.txt"
      echo     padding: 0; >> "asd.txt"
      echo     border: 0; >> "asd.txt"
      echo     font-size: 100%%; >> "asd.txt"
      echo     font: inherit; >> "asd.txt"
      echo     vertical-align: baseline; >> "asd.txt"
      echo } >> "asd.txt"
      echo /* HTML5 display-role reset for older browsers */ >> "asd.txt"
      echo article, aside, details, figcaption, figure,  >> "asd.txt"
      echo footer, header, hgroup, menu, nav, section { >> "asd.txt"
      echo     display: block; >> "asd.txt"
      echo } >> "asd.txt"
      echo body { >> "asd.txt"
      echo     line-height: 1; >> "asd.txt"
      echo } >> "asd.txt"
      echo ol, ul { >> "asd.txt"
      echo     list-style: none; >> "asd.txt"
      echo } >> "asd.txt"
      echo blockquote, q { >> "asd.txt"
      echo     quotes: none; >> "asd.txt"
      echo } >> "asd.txt"
      echo blockquote:before, blockquote:after, >> "asd.txt"
      echo q:before, q:after { >> "asd.txt"
      echo     content: ''; >> "asd.txt"
      echo     content: none; >> "asd.txt"
      echo } >> "asd.txt"
      echo table { >> "asd.txt"
      echo     border-collapse: collapse; >> "asd.txt"
      echo     border-spacing: 0; >> "asd.txt"
      echo } >> "asd.txt"
      echo Done.
      

      【讨论】:

      • 真的没有其他更短的方法了吗?
      • 您是否使用特殊字符 <>|& 对此进行了测试?
      • @Endoro TextZipper 自动转义它们:D
      • @MichałWesołowski 你可以试试 AutoHotkey! :)
      猜你喜欢
      • 2017-09-12
      • 1970-01-01
      • 2011-11-10
      • 2021-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-05
      相关资源
      最近更新 更多