我是当它涉及到PowerShell中完全完全一无所知,但下载一个巨大的洪流充满子目录(“publisher.title.author.year”基本上)各包含一个或多个zip文件,之后拉开时每个包含一个多文件rar arhive的一部分,最后一次汇编,其中包含一个(无用的名称)pdf文件...
所以我想出了这个粗略和准备好的脚本,以递归到每个子目录,解压缩拉到该目录中,然后组装rar文件并将pdf提取到该目录中,然后使用目录名称重命名pdf,然后将其移动到一个目录中(所以最后我以基础目录结束l有意义的命名pdf文件...
无论如何 - 就像我说的我几乎没有PowerShell的知识,所以我主要发布这个,因为我浪费了两个小时写它(我可以在5-10分钟内完成python或perl:P),因为如果它是在网络上我可能居然再次找到它,如果我需要嘿嘿
$subdirs = Get-ChildItem | ?{$_.Attributes -match 'Directory'}
foreach ($dir in $subdirs) {
cd $dir
$zip get-childitem | where {$_.Extension -match "zip"}
C:\7z.exe x -y $zip.FullName
$rar = get-childitem | where { $_.Extension -match "rar"}
C:\7z.exe x -y $rar
$pwd = get-item .
$newname = $pwd.basename+".pdf"
get-childitem *.pdf | rename-item -newname $newname
move-item $newname ..\
cd ..
}
我需要使用-o标志和逃生b C的/在路径中有空格的目录名称:'GCI -r - filter * .tar | foreach {c:\ 7z.exe x -y $ _。FullName -o“$('”'+ $ _。DirectoryName +'“'')”}' – lapropriu