Apple - Convert a number of zip file to rar?
What you could do is making a little batch file that would use RAR, a shareware command line utility for mac (I did not find any free rar command line utility, but RAR is available as a trial).
Installing rar command
To install RAR into your terminal, simply copy rar
and unrar
into your bin
folder.
To get access to the bin
directory, open Terminal.app and type
open /bin
The Windows version of RAR allows to "convert" zip
archive into rar
archive in tools, but the mac version doesn't seem to have this feature. The solution would be to unzip each of the files into separate folders and then to RAR content of those folders right away.
The Solution
#!/bin/bash
# shell script that will convert zip files into rar files
# Require RAR for Mac os x to be placed in bin folder
# Working directory, use ~ for home folder shortcut :)
WorkingDirectory=~/test
# Temp directory that will be used for zip files manipulation
# Will prevent loop from raring other folders ;)
TempDirectory="${WorkingDirectory}"/zipToRarTemp
# Target Directory is where you want the rar files to go after the process
TargetDirectory="${WorkingDirectory}"
# Let's create the directories
mkdir "${TempDirectory}"
mkdir "${TargetDirectory}"
# Will loop into WorkingDirectory and unzip each .zip files
for file in "${WorkingDirectory}"/*.zip
do
# Get file name
# See http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash
# 1st answer
filename=$(basename "$file")
extension="${filename##*.}"
filename="${filename%.*}"
# Temp folder in the loop
tempFolderToRar="${TempDirectory}"/"${filename}"
# Create folders to rar later
mkdir "${tempFolderToRar}"
# unzip -d folder/extract/to fileToExtract.zip
unzip -d "${TempDirectory}"/"${filename}" "${file}"
# rar all the files in tempFolderToRar into the target
rar a "${TargetDirectory}"/"${filename}".rar "${tempFolderToRar}"
done
# Optionnaly, delete temp directory if different from target
if [ "${TempDirectory}" != "${TargetDirectory}" ]
then
rm -r "${TempDirectory}"
fi
Save this to a file with no extension, be sure to set the good paths in the first variables and it should work fine running it in terminal.app
Conclusion
Well, It worked for me.
Note: this script is not perfect. Maybe there's a better way, but it works ;) that was one of my first shell script, would probably be better with parameters, or go with python ;)
Hope it helps.
Here's a simpler script like the one posted by GabLeRoux. rar
can be downloaded from from http://www.rarlab.com/download.htm.
#!/bin/bash
for f in ~/Desktop/*.zip; do
d=/tmp/$(uuidgen)
unzip "$f" -d $d
cd "$d"
rm -rf __MACOSX
~/bin/rar a "${f%zip}rar" *
rm -r "$d"
done