netmjwork 发表于 2018-3-19 18:55:16

不知 发表于 2016-12-20 12:22
不好意思,帖子中的文字打错了,把%1打成了%%i。帖子已更正。
——————————————————— ...

还得请教“不知”大师:上次您给出两个批处理很好用,现在条件变化些,自己尝试修改批处理,但不成功,请大师指点下,非常感谢!

上次的问题是:用批处理将连续数字的 1.ts、2.ts 等文件名称 “添加0” “补齐位数”,然后再一起合并
这次条件变成    1、2等文件名(没有.后缀),后面操作是一样的,请教大师该怎么修改?

这次希望解决两个问题:(附上上次您给的完整代码,方便您修改)
1、上次的批处理文件名由“1.ts、2.ts、3.ts”变成没有后缀的“1、2、3”批处理该怎么修改,其他操作完全一致
2、示例是对4位数字名称的修改,最小 0001 ,最大 9999 ,如果位数是 3 位 ,或 5 位,该在哪里修改下?

=======================================================         全部 .ts文件_ “添加 0 ” “补齐 4 位数 ” _复制合并

@echo off
rem 设置文件后缀名
set suf=ts

goto :step1
:step1
for /f %%i in ('dir /a /b *.%suf%') do call :deal1 %%i
goto :step2

:deal1
set temp=%1

if %temp:~1,1%x==.x move /Y %temp% 000%temp%
if %temp:~2,1%x==.x move /Y %temp% 00%temp%
if %temp:~3,1%x==.x move /Y %temp% 0%temp%
goto :EOF

:step2

copy /b *.ts zz_out_all.ts

goto :EOF

=======================================================         指定范围的 .ts文件_ “添加 0 ” “补齐 4 位数 ” _复制合并

@echo off
rem 设置文件后缀名
set suf=ts

goto :step1
:step1
for /f %%i in ('dir /a /b *.%suf%') do call :deal1 %%i
goto :step2

:deal1
set temp=%1

if %temp:~1,1%x==.x move /Y %temp% 000%temp%
if %temp:~2,1%x==.x move /Y %temp% 00%temp%
if %temp:~3,1%x==.x move /Y %temp% 0%temp%
goto :EOF

:step2
set /p start=分组开始的编号:
set /p end=分组结束的编号:
set /p dir=临时复制暂存目录名:

if not exist %dir% mkdir %dir%

for /f %%i in ('dir /a /b *.%suf%') do call :deal2 %%i

copy /B %dir%\*.%suf% %dir%\out.%suf%

rem 移动文件当前目录

if exist %dir% move /Y %dir%\out.%suf% out_%dir%.%suf%

rem 如要删出中间文件/文件夹,请将下一行的rem删除

rem if exist %dir% RD /S /Q %dir%

set /p ch=想要继续吗(Y/N(默认Y))?
if not defined ch goto :step2
if defined ch if /I %ch:~,1%==N exit
if defined ch if /I %ch:~,1%==Y goto :step2

goto :EOF

:deal2

set temp=%1

if %temp:~,4% GEQ %start% if %temp:~,4% LEQ %end% copy /B %temp% %dir%\%temp%

goto :EOF

=======================================================      
页: 1 [2]
查看完整版本: 【已解决】“copy”命令合并视频文件,文件名纯数字排列,如何按指定范围合并?