Powershell:根据两个文件夹中的内容处理两个文件夹中的文件

发布于 2024-10-07 05:27:30 字数 183 浏览 0 评论 0原文

我有两个目录:c:\Rar 和 c:\unRared

Rar - 包含数百个 RAR 文件。 RAR 中只有一个文件。存档内的文件扩展名为 *.TRN。 UnRared 具有未归档的文件(数百个带有 *.TRN 扩展名的文件)

我一直在尝试创建一个 Powershell 脚本来仅提取尚未提取的文件

I have two directories: c:\Rar and c:\unRared

Rar - contains hundreds of RAR'ed files. Only one file inside the RAR. File inside the archive is with *.TRN extension.
UnRared has unarchived files (hundreds of files with *.TRN extension)

I've been trying to create a Powershell script to extract only files that have not been extracted already.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

找回味觉 2024-10-14 05:27:30

难道您不能只向您拥有的任何压缩程序提供参数,告诉它不要覆盖现有文件吗?

can't you just supply parameters to whatever compression program you have telling it not to overwrite existing files?

霞映澄塘 2024-10-14 05:27:30

我自己解决了这个问题...好吧,不是真的,在开发人员的帮助下

$dir1='C:\temp\aaa'
$dir2='C:\temp\bbb'
$CmdPath = "C:\Program Files (x86)\WinRAR\RAR.exe"
$Files2Extract = get-childitem -path 'C:\temp\aaa' -recurse -name -filter *.rar
#$d2 = get-childitem -path $dir2 -recurse

foreach($file in $Files2Extract){
    $justname =  $dir2+'\\'+(split-path $file -leaf).split(".")[0]+'.trn'

    if(!(Test-Path -path $justname)) {
        &$CmdPath e $file $dir2
    }

} 

Knocked this out on my own...well, not really, with the help of developer

$dir1='C:\temp\aaa'
$dir2='C:\temp\bbb'
$CmdPath = "C:\Program Files (x86)\WinRAR\RAR.exe"
$Files2Extract = get-childitem -path 'C:\temp\aaa' -recurse -name -filter *.rar
#$d2 = get-childitem -path $dir2 -recurse

foreach($file in $Files2Extract){
    $justname =  $dir2+'\\'+(split-path $file -leaf).split(".")[0]+'.trn'

    if(!(Test-Path -path $justname)) {
        &$CmdPath e $file $dir2
    }

} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文