搞了一个很sb的方式,先凑合着用了。。- @echo off
-
- set /p file_load=请输入文件路径(例如D:\test,默认当前路径):
- cd /d %file_load%
-
- setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('dir /b .') do (
- echo %%a
- )
-
-
- ::使用set进行设置变量,并使用/p参数让命令暂停运行,提供用户在cmd窗口输入变量的机会
- set /p var=请输入要解压的文件名称(以,分割,输入0默认全部解压):
-
- if "%var%" == "0" (
- dir /b *.*>extract_test002.txt
- )else (
- @echo %var% > extract_test001.txt
-
-
- ::将之前的文件中,替换为换行符,重新生成文件
- for /f %%h in ('copy /z %0 nul') do set crlf=%%h^
-
-
- (for %%h in ("!crlf!") do (
- for /f "delims=" %%b in (extract_test001.txt) do (
- endlocal
- set "str=%%b"
- setlocal enabledelayedexpansion
- echo !str:,=%%~h!
- )
- ))>extract_test002.txt
- del extract_test001.txt)
-
-
- set n=0
- for /f "delims=" %%b in ('type "extract_test002.txt"') do set /a n+=1
-
- ::批量解压
- set t=0
- for /f "delims=" %%i in (extract_test002.txt) do (
- set /a t=!t!+1
- echo -------------------------------解压第!t!个文件,一共有%n%个文件---------------------.
- "C:\Program Files\7-Zip\7z.exe" x %%i -y -aos -o.\%%~ni\
- )
-
- del extract_test002.txt
-
- pause
复制代码
|