gpt4 book ai didi

Powershell 和 winrar 命令行

转载 作者:行者123 更新时间:2023-12-03 09:41:07 30 4
gpt4 key购买 nike

因此,在挖掘了一天左右之后,我没有发现太多有关 powershell 和使用 winrar 命令行提取文件的信息。

我的困难在于参数和命令行的实际执行。

到目前为止,这是我的简单代码:

$WinRar = "C:\Program Files\WinRAR\winrar.exe"

#filter through files looking for zip files.
$path = get-ChildItem -filter "*.zip" -path A:\testfolder\ -recurse

#test to see if it is actually filtering and showing correct results:
write-host = $path | format-table directory

#arguments :: x (extract) y(presume yes) r(recurse subdir)
&$WinRar x -y -r "$path" A:\Testfolder\



read-host "press to exit"

我对 powershell 很陌生,似乎很快就流行起来,但我假设我在代码执行时完全错误,但它没有提取。所以我猜它在命令行的某个地方出错了,我看不到它在做什么。

他们有什么建议或提示可以为我指明正确的方向吗?

我已经尝试了 $winrar 命令的许多变体,但没有运气,除非我将 $path 替换为它工作的实际文件路径..这不是我需要的:P

最佳答案

您可以为此使用简单的 foreach 方法:

$Zips = Get-ChildItem -filter "*.zip" -path A:\testfolder\ -Recurse
$Destination = 'C:\Extracted'
$WinRar = "C:\Program Files\WinRAR\winrar.exe"

foreach ($zip in $Zips)
{
&$Winrar x $zip.FullName $Destination
Get-Process winrar | Wait-Process
}

如果您希望多个 WinRAR 进程一起运行,请删除 Get-Process线

关于Powershell 和 winrar 命令行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34719430/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com