我正在尝试解压文件夹中的大量档案。我尝试将它们存档在外面,而不是为每个档案创建一个文件夹。
我正在使用这个代码
@echo off
setlocal
rem Set the path to the 7-Zip executable
set "7z_path=C:\Program Files\7-Zip\7z.exe"
rem Set the path to the folder containing the archives
set "source_folder=C:\Users\blabla"
rem Echo the paths for debugging
echo 7z_path is set to: "%7z_path%"
echo source_folder is set to: "%source_folder%"
rem Change to the source folder
cd /d "%source_folder%"
rem Extract each archive file in the folder
for %%i in (*.zip *.rar *.7z) do (
"%7z_path%" x "%%i" -aoa -o"%source_folder%"
)
endlocal
pause
但它不适用于以下错误
'"z_pathsource_folder"' is not recognized as an internal or external command, operable program or batch file.
在调试时,我注意到这
7z_path is set to: "z_path"
显然是错误的,但我不明白我做错了什么。这个问题可能导致上述错误。
任何帮助都值得感激,谢谢。
%1
批处理脚本的参数使用语法、%2
、等调用。%3
这些变量在脚本中的所有其他变量之前先展开为它们的值。由于您调用的是变量%7z_path%
,因此它被解释为%7
后面跟着字符串z_path%
。将变量名更改为不以数字开头的名称,例如
%sevenzip_path%
。