Board logo

标题: [文件操作] 如何批量合并多个子文件夹里的多个txt文件并按文件夹顺序批量重命名 [打印本页]

作者: booting    时间: 2017-6-14 14:48     标题: 如何批量合并多个子文件夹里的多个txt文件并按文件夹顺序批量重命名

如图,请各位大大帮忙
作者: ivor    时间: 2017-6-14 16:53

  1. @echo off&setlocal ENABLEDELAYEDEXPANSION
  2. set num=1
  3. set 文件夹a=C:\a\
  4. for /f "delims=" %%a in ('dir /s /b /ad "%文件夹a%" 2^>nul') do (
  5. set "source="
  6. cd /d %%a
  7. for /f "delims=" %%b in ('dir /b *.txt 2^>nul') do (
  8. set "source=!source!+%%b"
  9. )
  10. set source=!source:~1!
  11. copy !source! "%文件夹a%!num!.txt"
  12. cd
  13. set/anum+=1
  14. )
复制代码

作者: booting    时间: 2017-6-16 08:28

回复 2# ivor
非常感谢!
追问另外的一种情况,假如不是txt文件,是*.ts文件(一种视频格式),只能用二进制的copy /b *.ts 1.ts合并,无法用source=!source!+%%b来合并,这种情况下批处理该如何做?




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