我正在尝试编写一个将多个 css 文件组合到一个文件中的批处理脚本。到目前为止,我已经想出了这个......
# Set start folders & files
set fn1=filename.css
set fn2=another-filename.css
set fn3=yet-another-filename.css
# get filename add to temp file inside comment syntax
echo /* %fn1% >> tmp.css
echo. --------------------------------------------------------------- */ >> tmp.css
echo. >> tmp.css
# copy file contents
copy/b %fn1% + tmp.css
# repeat with other files...
echo /* %fn2% >> tmp.css
echo. --------------------------------------------------------------- */ >> tmp.css
echo. >> tmp.css
copy/b %fn2% + tmp.css
...
rename tmp.css combined-files.css
move combined-files.css \new-folder\combined-files.css
问题是它产生以下
/* filename.css
--------------------------------- */
/* another-filename.css
--------------------------------- */
/* ... */
[styles from filename.css]
[styles from another-filename.css]
....
我哪里错了?
谢谢
ps 我尝试使用 ms-dos FOR 命令简化上述内容也很糟糕。
set commentpt1=\*
set commentpt2=----------------------------------------- *\
FOR /F %%I IN ('DIR /s C:\[folder location]') DO echo %commentpt1% %%~nI 0x0A %commentpt2% 0x0A 0x0A >> temp.css copy/b %%I + tmp.css >> temp.css