PoshCode Archive  Artifact [65817a7dd0]

Artifact 65817a7dd03550f8f21c128baccf2b9fa0dd9c3098874b57f20f318d7a73ef0a:

  • File Convert-CBZ2CBR.ps1 — part of check-in [e26648fa2e] at 2018-06-10 14:24:44 on branch trunk — Converts CBZ files to CBR (user: unknown size: 1730)

# encoding: ascii
# api: powershell
# title: Convert-CBZ2CBR
# description: Converts CBZ files to CBR
# version: 1.0
# type: script
# license: CC0
# x-poshcode-id: 837
# x-archived: 2009-02-04T17:22:16
#
# Simple script I wrote to run on a directory of CBZ (ZIP file) files to convert them to CBR (RAR file)
#
###########################################################################
#
# NAME: Convert-CBZ2CBR.ps1
#
# AUTHOR: Neiljmorrow
# EMAIL: Neiljmorrow@gmail.com
#
# NOTE:	Written to use command line version of 7zip (http://7zip.com)
#	from the default install location. Please modify the path below
#	if necessary.
#
# COMMENT:
#
# You have a royalty-free right to use, modify, reproduce, and
# distribute this script file in any way you find useful, provided that
# you agree that the creator, owner above has no warranty, obligations,
# or liability for such use.
#
# VERSION HISTORY:
# 1.0 1/24/2009 - Initial release
#
###########################################################################

#set alias to command line version of 7zip
set-alias cbrzip "c:\program files\7-zip\7z.exe"

#find all files in the immediate directory 
dir "*.cbz" | foreach-object{

	#Make a copy and rename as zip
	copy-item $_.name ($_.basename + ".zip")

	#unzip the file to a "temp" directory
	cbrzip -oTemp x ($_.basename + ".zip")
	
	#remove the zip file
	remove-item ($_.basename + ".zip")
	
	#rar the contents of the "temp" directory
	cbrzip a ($_.basename + ".rar") "temp"

	#remove the "temp" directory
	remove-item -r "temp"

	#rename the rar file to cbr	
	rename-item ($_.basename + ".rar") ($_.basename + ".cbr")
}

#remove 7zip alias
remove-item alias:cbrzip