我正在尝试取消归档文件夹中的大量档案。我正在尝试将它们存档在外部,而不为每个存档创建一个文件夹。
我正在使用此代码
@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"
这显然是不正确的,但我不明白我做错了什么。这个问题可能会导致上述错误。
感谢任何帮助,ty。
批处理脚本的参数使用语法
%1
、%2
、%3
等调用。这些变量在脚本中的所有其他变量之前扩展为其值。因为您正在调用变量 %7z_path%
,所以它被解释为 %7
后跟字符串 z_path%
。
将变量名称更改为不以数字开头的名称,例如
%sevenzip_path%
。