开发者

Powershell: processing files in two folders based on what's in them

开发者 https://www.devze.com 2023-01-29 18:34 出处:网络
I have two directories: c:\\Rar and c:\\unRared Rar - contains hundreds of RA开发者_C百科R\'ed files. Only one file inside the RAR. File inside the archive is with *.TRN extension.

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

Rar - contains hundreds of RA开发者_C百科R'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.


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


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
    }

} 
0

精彩评论

暂无评论...
验证码 换一张
取 消