我在尝试使用解压缩文件时遇到一个小问题7za http://7-zip.org/download.htmlPowershell 中的命令行实用程序。
我设置了$zip_source
变量为 zip 文件的路径和$unzip_destination
到所需的输出文件夹。
但是命令行用法7za
需要这样指定的参数:
7za x -y <zip_file> -o<output_directory>
所以我当前的通话如下所示:
& '7za' x -y "$zip_source" -o$unzip_destination
由于事实上之间不能有空格-o
和目的地它
似乎 PowerShell 不会扩展$unzip_destination
变量,而$zip_source
被扩展。
目前该程序只是将所有文件提取到根目录中C:\
在
一个名为$unzip_destination
。
在变量周围设置不同类型的引号也不起作用:
-o"$unzip_destination" : still extracts to C:\$unzip_destination
-o'$unzip_destination' : still extracts to C:\$unzip_destination
-o $unzip_destination : Error: Incorrect command line
有没有办法在运行命令之前强制扩展?
尝试这个:
& '7za' x -y "$zip_source" "-o$unzip_destination"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)