Board logo

标题: [文本处理] 批处理set files 一行太长了,怎样折行? [打印本页]

作者: oyr520    时间: 2022-1-8 12:02     标题: 批处理set files 一行太长了,怎样折行?

set files="test.bin" "test2.bin" "note.txt" "ext" "release_rar" "release_rar2" "release_rar3" "doc" "release_rar5"
set com=".\custom\project\abc\include\com.h"

想要下面这样的效果
set files="test.bin" "test2.bin" "note.txt" "ext"
"release_rar" "release_rar2"
"release_rar3" "doc" "release_rar5"
set com=".\custom\project\abc\include\com.h"
作者: went    时间: 2022-1-8 13:13

  1. @echo off & cd /d "%~dp0"
  2. set files="test.bin" "test2.bin" "note.txt" "ext"
  3. set files=%files% "release_rar" "release_rar2"
  4. set files=%files% "release_rar3" "doc" "release_rar5"
  5. set com=".\custom\project\abc\include\com.h"
  6. echo %files%
  7. echo %com%
  8. pause&exit
复制代码

作者: Nsqs    时间: 2022-1-8 16:17

本帖最后由 Nsqs 于 2022-1-8 16:33 编辑

这要是怕麻烦那就干脆不要写代码了
  1. @echo off
  2. for /f "tokens=1 delims=:" %%1 in ('findstr /ni "^::data$" "%~0"')do (
  3. set count=%%1
  4. )
  5. for /f "delims=" %%1 in ('more +%count%^<"%~0"')do (
  6. call set file=%%file%% %%1
  7. )
  8. echo %file%
  9. pause
  10. goto :eof
  11. ::data
  12. "test.bin" "test2.bin" "note.txt" "ext"
  13. "release_rar" "release_rar2" "release_rar3"
  14. "doc" "release_rar5"
复制代码





欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2