Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #CBR to #CBZ
- #getfile list from user (determine if it's a folder or a text file)
- function GetFileList {
- $comicPath="c:\users\alex\desktop\cbr2cbz\"
- #$comicPath=Read-Host "Please enter path to comics, or txt file with comics (include trailing directory markers)"
- if ([string]::IsNullOrEmpty($comicPath) -or (Test-Path -LiteralPath $comicPath) -ne $true) {
- Write-host "Path not valid, please try again"
- GetFileList
- }
- else {
- if ((get-item $comicPath) -is [System.IO.DirectoryInfo]) {
- FolderPath
- }
- if ((get-item $comicPath) -isnot [System.IO.DirectoryInfo]) {
- FilePath
- }
- }
- }
- #if path is to a folder
- function FolderPath {
- $fileList = Get-ChildItem -filter "*.cb*" -recurse "$comicPath"
- foreach ($x in $fileList) {
- write-host "sending $x to get fixed"
- FixFileExtensions -filename ($x.FullName)
- write-host "file fixed, sending another"
- }
- FolderPathUnRAR
- }
- #unrar contents
- function FolderPathUnRAR {
- $fileList = Get-ChildItem -filter "*.cbr" -recurse "$comicPath"
- foreach ($x in $fileList) {
- cd $comicpath
- mkdir $x.BaseName
- Write-Output "newfilename (only CBR's): $x"
- &$unrarPath e -v ($x).FullName ($x).basename 2>&1 | Tee-Object -Variable unrarOutput
- $unrarOutput | ForEach-Object {
- if($_ -like "*is not RAR archive*" -or $_ -like "*checksum error") {
- "$($x.FullName) has an error: $_" | out-file -append ".\test.txt"
- }
- }
- }
- }
- function FilePath {
- }
- #fix file extensions with Trid
- function FixFileExtensions {
- param($filename)
- write-output "recieved $filename, processing"
- &$tridPath -v -ce "$filename" -d:$tridDef
- Write-Output "Trid done did it's stuff"
- return
- }
- #get and check unrar path
- $unrarPath = $(Get-Command 'unrar').Definition
- if ( $unrarPath.Length -eq 0 ) {
- Write-Error "Unable to access unrar at location '$unrarPath'."
- $unrarPath="C:\unrar\unrar.exe"
- #$unrarPath=Read-Host -Prompt "Please enter path to Unrar"
- if ([string]::IsNullOrEmpty($unrarPath) -or (Test-Path -LiteralPath $unrarPath) -ne $true) {
- Write-Error "Unrar.exe path does not exist '$unrarPath'."
- }
- else {
- Write-host "Path is good: $unrarPath"
- }
- }
- else {
- write-host "unrar found, using path: '$unrarPath'"
- }
- #get and check path to trid
- $tridpath="Z:\Comics\cbr2cbz\app\trid.exe"
- #$tridpath=Read-Host -Prompt "Please enter path to trid"
- if ([string]::IsNullOrEmpty($tridPath) -or (Test-Path -LiteralPath $tridPath) -ne $true) {
- Write-Error "Trid path does not exist '$tridPath'."
- }
- else {
- Write-host "Path is good: $tridPath"
- }
- #Get and check path to trid def file
- $tridDef="Z:\Comics\cbr2cbz\app\cbx.trd"
- #$tridDef=Read-Host -Prompt "Please enter path to trid definition file"
- if ([string]::IsNullOrEmpty($tridDef) -or (Test-Path -LiteralPath $tridDef) -ne $true -or $tridDef -notlike "*.trd") {
- Write-Error "TridDefinition path does not exist '$tridDef'."
- }
- else {
- Write-host "Path is good: $tridDef"
- }
- GetFileList
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement