使用 7zip 提取文件并重命名具有特定扩展名的特定文件?

Extract files and rename specific file with specific extension using 7zip?

我想使用 7ZIP 仅提取具有特定扩展名的文件,然后相应地重命名其中一个文件。

此外,我必须使用批处理脚本 (.bat) 执行此操作 - 没有 powershell 或其他方法。

我目前在 bat 文件中设置了以下脚本:

@echo off
REM Force UTF-8 to fix some output problems
chcp 65001 > nul

REM Six columns, space delimited
for /f "tokens=6 delims= " %%A in ('"C:\Toolsza.exe" l VPN.zip -ba -r *\*.ovpn') do (
    "C:\Toolsza.exe" e VPN.zip -ba -r %%A > Test.ovpn
)

PAUSE

输出:

It exracts two files.

One is the archive itself (Archive...ovpn) The second one is the one i renamed (Test.ovpn) The second archive, instead of being the actual renamed archive, contains 7Zip logs... Log is below.

Processing archive: VPN.zip

Extracting  folder_name\Original_archive.ovpn

Everything is Ok

Size:       411 Compressed: 5800

它列出了我的压缩存档中的文件...

我想要实现的是:

Extract files only to a folder called "VPN", and not folder_name.

If the files contains the extension .ovpn, rename that file to "Test.ovpn"

如果这个问题看起来很愚蠢,我很抱歉。 我是批处理脚本领域的新​​手,这里是我唯一可以获得帮助的地方...

感谢所有帮助过我的人。

编辑:我用我正在使用的代码更新了问题,因为在评论中他们说这个问题不够清楚...

我用下面的代码解决了这个问题:

REM Extract files in archive
for %%f in (VPN.zip) do (

"C:\Toolsza.exe" e "%%f" -ba -y -so -r *\*.ovpn 1>C:\VPN\VPN.ovpn 2>nul
"C:\Toolsza.exe" e "%%f" -ba -y -r *\*.p12 -oC:\VPN >nul
"C:\Toolsza.exe" e "%%f" -ba -y -r *\*.key -oC:\VPN >nul

) >nul