powershell - 在 powershell 中使用 7-zip
问题描述
我想从 csv.gz zip 文件中提取 csv 文件。我已经下载了 7-zip 并尝试使用以下代码:
$7zprogram = "C:\Program Files\7-Zip\7z.exe"
$sourcefile = "C:\Users\Mitesh\Desktop\file.csv.gz"
$destination = "C:\Users\Mitesh\Desktop\"
& $7zprogram e $sourcefile "-o$destination"
这不起作用,我收到一条错误消息,因为“术语“C:\Program Files\7-Zip\7z.exe”未被识别为 cmdlet、函数......”。
可能是什么问题?如果缺少某些内容,有人可以帮我更正这里的代码。
解决方案
听起来Powershell找不到7z.exe。
您可以使用以下版本的代码来测试这个理论:
$7zprogram = "C:\Program Files\7-Zip\7z.exe"
$sourcefile = "C:\Users\Mitesh\Desktop\file.csv.gz"
$destination = "C:\Users\Mitesh\Desktop\"
if(Test-Path -Path $7zprogram){
& $7zprogram e $sourcefile "-o$destination"
}else{
Write-Host "7z.exe does not exist";
}
我假设它会输出7z.exe does not exist
。如果是这样,请确保您安装了 7zip,并且它的文件名和路径正确(我测试了您的命令并且它在语法上是正确的/应该可以工作)。您的问题几乎可以肯定是这一行:$7zprogram = "C:\Program Files\7-Zip\7z.exe"
推荐阅读
- r - 在 shinyapps.io RShiny 应用程序中使用 h2o 包
- kubernetes - 仅在 tidb 集群中由于 tidb pod 中的连接被拒绝而导致准备就绪问题失败
- python - 如何在 Python 中“堆叠”嵌套列表?
- influxdb-python - 如何从 Python 客户端为 InfluxDB 指定 range() 中的绝对时间?
- go - What errors are outputted to http.Server's ErrorLog struct field?
- python - 如何在字典中附加所有重复的字符串名称以使其成为对象列表?
- javascript - 为什么未定义元素数组上的`join()`在javascript中返回少1个元素?
- javascript - Whatsapp 只分享 window.location.search 的第一个参数
- spring-boot - 部署一个 Spring Boot 应用的战争到本地 Tomcat 服务器:404 响应
- c# - 构建 .NET4.8 WinForm 时出现问题,配置设置会引发错误。在 Build:Debug|Release 输出文件夹中工作正常