【发布时间】:2018-10-11 06:49:23
【问题描述】:
这是我在 powershell 中的脚本
$today = (Get-Date).ToString('dd_MM_yyyy')
$LocalPath = "C:\Builds\$today"
New-Item -ItemType directory -Path $LocalPath
$RemotePath = "C:\Builds\zip\$today"
$Max_hours = "-5"
#Max_mins = "-5"
$Curr_date = get-date
#Checking date and then copying file from LocalPath to RemotePath
Foreach($file in (Get-ChildItem $RemotePath))
{
if($file.LastWriteTime -gt ($Curr_date).addhours($Max_hours))
{
Get-ChildItem "C:\Builds\zip\$today\*pc*.*" | % {& "C:\Program Files\7-Zip\7z.exe" "x" "-aoa" $_.fullname "-oC:\Builds\$today"}
}
ELSE
{"not extracting $file"
}
}
我有几个 *.zip 文件,我想将它们提取到特定文件夹中。问题是,7zip 使用 *.zip 名称创建子文件夹并将文件提取到此文件夹中。
例如。我有 a.zip、b.zip 和 c.zip 文件,我希望将它们准确地提取到 Builds 文件夹中。现在,在我的命令之后,它们被提取到:
构建/a/(此处为 a.zip 文件)
Builds/b/(这里是 b.zip 文件)
Builds/c/(这里是 c.zip 文件)
我希望它们都位于具有完整目录路径的 Builds/(此处为 a、b、c 文件)中。 shell中是否有任何7zip选项可以做到这一点?
'-e' 选项提取所有没有文件夹路径的文件,这就是我现在要寻找的。
【问题讨论】:
标签: windows powershell