[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] 批处理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"

  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
复制代码

TOP

本帖最后由 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"
复制代码

TOP

返回列表