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

[文件操作] 批处理怎样根据输入的起始文件名解压缩文件?

假设目录下众多rar文件,文件名规律如下表,想要实现功能,输入起始文件名值:如20190801    输入终止文件名值:如20191120   解压指定范围的rar文件到指定目录内 (解压20190801_L2D.rar ------20191120_L2D.rar范围内的文件)

(@echo off & title 批量解压并分类文件

cd /d %~dp0

set WinRarDir=%ProgramFiles%\WinRAR

set Path=%Path%;%WinRarDir%

unrar e -OR *.rar   F:\导出
pause
goto :eof)

能力有限只能解压目录下所有rar文件到指定目录




20190729_L2D.rar
20190730_L2D.rar
20190731_L2D.rar
20190801_L2D.rar
20190802_L2D.rar
20190806_L2D.rar
20190807_L2D.rar
20190808_L2D.rar
20190809_L2D.rar
20190812_L2D.rar
20190813_L2D.rar
20190814_L2D.rar
20190815_L2D.rar
20190816_L2D.rar
20190819_L2D.rar
20190820_L2D.rar
20190821_L2D.rar
20190822_L2D.rar
20190823_L2D.rar
20190826_L2D.rar
20190827_L2D.rar
20190828_L2D.rar
20190829_L2D.rar
20190830_L2D.rar
20190902_L2D.rar
20190903_L2D.rar
20190904_L2D.rar
20190905_L2D.rar
20190906_L2D.rar
20190909_L2D.rar
20190910_L2D.rar
20190911_L2D.rar
20190912_L2D.rar
20190916_L2D.rar
20190917_L2D.rar
20190918_L2D.rar
20190919_L2D.rar
20190920_L2D.rar
20190923_L2D.rar
20190924_L2D.rar
20190925_L2D.rar
20190926_L2D.rar
20190927_L2D.rar
20190930_L2D.rar
20191008_L2D.rar
20191009_L2D.rar
20191010_L2D.rar
20191011_L2D.rar
20191014_L2D.rar
20191015_L2D.rar
20191016_L2D.rar
20191017_L2D.rar
20191018_L2D.rar
20191021_L2D.rar
20191022_L2D.rar
20191023_L2D.rar
20191024_L2D.rar
20191025_L2D.rar
20191028_L2D.rar
20191029_L2D.rar
20191030_L2D.rar
20191031_L2D.rar
20191101_L2D.rar
20191104_L2D.rar
20191105_L2D.rar
20191106_L2D.rar
20191107_L2D.rar
20191108_L2D.rar
20191111_L2D.rar
20191112_L2D.rar
20191113_L2D.rar
20191114_L2D.rar
20191115_L2D.rar
20191118_L2D.rar
20191119_L2D.rar
20191120_L2D.rar
20191121_L2D.rar
20191122_L2D.rar
20191125_L2D.rar
20191126_L2D.rar
20191127_L2D.rar
20191128_L2D.rar
20191129_L2D.rar
20191202_L2D.rar
20191203_L2D.rar
20191204_L2D.rar
20191205_L2D.rar

我发了一个计算日期的帖子,你去参考一下吧!

TOP

我发了一个计算日期的帖子,你去参考一下吧!
Gin_Q 发表于 2020-2-6 18:03



看不明白
:lol

TOP

使用for /l参数来解决。下面是原理,需结合你的代码
set /p ksz=输入开始值---》
set /p jsz=输入结束值---》
for /l %%i in (%ksz%,1,%jsz%) do unrar e -OR %%i_L2D.rar   F:\导出
目的,学习批处理

TOP

回复 4# hlzj88


    排除一下不存在的日期吧
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

这个是计算日期的,其他的你自己摸索一下吧!
  1. @echo off & setlocal enabledelayedexpansion &rem by author Gan
  2. set /p "time_end=请输入停止日期(格式:2020/01/01):"
  3. set /p "time_go=请输入起始日期(格式:20200101):"
  4. del /q old_date.txt 1>nul 2>nul
  5. >old_date.txt (for /l %%a in (1,1,999) do (
  6. set /a nd=%%a
  7. call :runnian %time_end:~0,4%
  8. call :test
  9. if !m! lss 10 set m=0!m!
  10. if !d! lss 10 set d=0!d!
  11. echo !y!!m!!d!
  12. if !y!!m!!d! equ %time_go% goto :pa
  13. ))
  14. :pa
  15. pause & eixt
  16. ::exit /b 0
  17. :test
  18. for /f "tokens=1-3 delims=/ " %%a in ("%time_end%") do (set /a y=%%a, m=1%%b%%100, d=1%%c%%100)
  19. if !nd! lss %d% (set /a d-=nd & goto :eof)
  20. set /a d_m=m-1, exd=0
  21. for /l %%a in (1,1,!d_m!) do (set /a exd+=m%%a)
  22. set /a exd+=d
  23. if !nd! GEQ %exd% (set /a nd-=exd, m=12, y-=1
  24.   call :runnian !y! ) else (set /a nd-=d, m-=1)
  25. :loop
  26. if !nd! GTR !count! (set /a nd-=!count!, m=12, y-=1& call :runnian !y!& goto :loop)
  27.   for /l %%a in (1,1,2) do (
  28.   if !m! LEQ 0 (set /a m=12, y-=1 & call :runnian !y!)
  29.   set /a md = m!m!
  30.   if !nd! lss !md! (set /a d=md-nd & goto :eof)
  31.   set /a nd-=md, m-=1
  32.   goto :loop)
  33. :runnian
  34. set /a m1=31, m2=28, m3=31, m4=30, m5=31, m6=30, m7=31, m8=31, m9=30, m10=31, m11=30, m12=31
  35. set /a n=0
  36. set /a a=%1%%4,a1=%1%%100,a2=%1%%400
  37. if !a! equ 0 set n=1& if !a1! equ 0 set n=0
  38. if !a2! equ 0 set n=1
  39. if !n! equ 1 (set /a m2=29, count=366) else (set /a m2=28, count=365)
  40. goto :eof
复制代码

TOP

返回列表