【发布时间】:2015-01-24 17:43:00
【问题描述】:
Trying to extract just .sql files from zip powershell
参考上面的链接,制作了一个 powershell 脚本来仅提取 .sql 文件。
有没有办法扭转这种情况,所以它会从 Zip 文件中提取除 .Inf 文件之外的所有内容。
任何帮助都将不胜感激,因为我的 powershell 技能几乎没有。
$shell = New-Object -COM 'Shell.Application'
$zipfile = 'C:\Powershell\From here\1-5'
$destination = 'C:\Powershell\To Here'
$zip = $shell.NameSpace($zipfile)
$zip.Items() | ? { $_.Path -notlike '*.inf' } | % {
$shell.NameSpace($destination).CopyHere($_)
}
【问题讨论】:
-
文件全名是什么?
$zipfile似乎没有指向有效 zip 文件的路径。 -
它们的设置方式是在 C 中名为“Powershell”的普通文件夹中设置:然后在另一个名为“From Here”的普通文件夹中,然后在其中有三个名为“1-5”、“6-10”和“11-15”。然后在每个文件夹中,还有另外 5 个相应标记为 1-15 的 zip 文件夹。以及 2 个 .inf 文件。在每个最终的 zip 文件夹中都有一个文本文件。
标签: powershell zip