Sunday, January 09, 2011

mass convert rar to zip (or cbr to zip) in linux

found this script on ubuntu's forums. had to modify one part of it but seems to work in linux (though you will have to input the full source directory name) I didn't look too closely at the source though.
#!/bin/bash

# Set the "field separator" to something other than spaces/newlines" so that spaces
# in the file names don't mess things up. I'm using the pipe symbol ("|") as it is very
# unlikely to appear in a file name.
IFS="|"

# The script should be invoked as "cbr2cbz {directory}", where "{directory}" is the
# top-level directory to be searched. Just to be paranoid, if no directory is specified,
# then default to the current working directory ("."). Let's put the name of the
# directory into a shell variable called WORKDIR.
# Note: "$1" = "The first command line argument"
if test -z $1; then
WORKDIR="."
else
WORKDIR="$1"
fi
echo "Working from directory $WORKDIR"

# Now, execute a loop, based on a "find" command in the specified directory. The
# "-printf "$p|" will cause the file names to be separated by the pipe symbol, rather than
# the default newline. Note the backtics ("`") (the key above the tab key on US
# keyboards).
for CBRFILE in `find $WORKDIR -name "*.cbr" -printf "%p|"`; do
# Now for the actual work. First, extract the base file name (without the extension)
# using the "basename" command. Warning: more backtics.
BASENAME=`basename $CBRFILE ".cbr"`

# And the directory path for that file, so we know where to put the finished ".cbz"
# file. You could potentially hard code this to a single directory - your choice...
# backtics again...
DIRNAME=`dirname $CBRFILE`

# For the new file name, let's convert any spaces to underscores. We'll do this with
# a "sed" (stream editor) command. Backtics again.
NEWBASEFILE=`echo "$BASENAME" | sed "s/ /_/g"`

# Now, build the "new" file name,
NEWNAME="$NEWBASEFILE.cbz"

# We need a guaranteed empty directory to work in, so I'm creating a temp
# directory under the current working directory. It will be deleted when we're
# done with it:
mkdir cbr2cbztemp
cd cbr2cbztemp

# Now that the preliminaries are done, we start doing some work.
# We need to copy the ".cbr" into the current "temp" directory for
# unpacking/repacking.
cp "$CBRFILE" .

# rename the file to a ".rar" file. I don't think this is necessary, but it shouldn't
# cause any problems...
mv "$BASENAME.cbr" "$BASENAME.rar"

# Unpack the rar file
unrar e "$BASENAME.rar"

# Delete the .rar file
rm "$BASENAME.rar"

# Create the ".cbz" file
zip "$NEWNAME" *

# And move it to the directory where we found the original ".cbr" file
cp "$NEWNAME" "$DIRNAME"

# Finally, "cd" back to the original working directory, and delete the temp directory
# created earlier.
cd ..
rm -r cbr2cbztemp

# At this point, you could potentially 'rm "$CBRFILE"' to delete the original, but
# I'd suggest not doing so until you're certain you've got a good ".cbz" file...

done

.. honestly it was driving me crazy before I found this. I assume it works for rar to zip too but no guarantees that it doesn't trash your whole system.
#!/bin/bash

# Set the "field separator" to something other than spaces/newlines" so that spaces
# in the file names don't mess things up. I'm using the pipe symbol ("|") as it is very
# unlikely to appear in a file name.
IFS="|"

# The script should be invoked as "rar2zip {directory}", where "{directory}" is the
# top-level directory to be searched. Just to be paranoid, if no directory is specified,
# then default to the current working directory ("."). Let's put the name of the
# directory into a shell variable called WORKDIR.
# Note: "$1" = "The first command line argument"
if test -z $1; then
WORKDIR="."
else
WORKDIR="$1"
fi
echo "Working from directory $WORKDIR"

# Now, execute a loop, based on a "find" command in the specified directory. The
# "-printf "$p|" will cause the file names to be separated by the pipe symbol, rather than
# the default newline. Note the backtics ("`") (the key above the tab key on US
# keyboards).
for rarFILE in `find $WORKDIR -name "*.rar" -printf "%p|"`; do
# Now for the actual work. First, extract the base file name (without the extension)
# using the "basename" command. Warning: more backtics.
BASENAME=`basename $rarFILE ".rar"`

# And the directory path for that file, so we know where to put the finished ".zip"
# file. You could potentially hard code this to a single directory - your choice...
# backtics again...
DIRNAME=`dirname $rarFILE`

# For the new file name, let's convert any spaces to underscores. We'll do this with
# a "sed" (stream editor) command. Backtics again.
NEWBASEFILE=`echo "$BASENAME" | sed "s/ /_/g"`

# Now, build the "new" file name,
NEWNAME="$NEWBASEFILE.zip"

# We need a guaranteed empty directory to work in, so I'm creating a temp
# directory under the current working directory. It will be deleted when we're
# done with it:
mkdir rar2ziptemp
cd rar2ziptemp

# Now that the preliminaries are done, we start doing some work.
# We need to copy the ".rar" into the current "temp" directory for
# unpacking/repacking.
cp "$rarFILE" .

# rename the file to a ".rar" file. I don't think this is necessary, but it shouldn't
# cause any problems...
mv "$BASENAME.rar" "$BASENAME.rar"

# Unpack the rar file
unrar e "$BASENAME.rar"

# Delete the .rar file
rm "$BASENAME.rar"

# Create the ".zip" file
zip "$NEWNAME" *

# And move it to the directory where we found the original ".rar" file
cp "$NEWNAME" "$DIRNAME"

# Finally, "cd" back to the original working directory, and delete the temp directory
# created earlier.
cd ..
rm -r rar2ziptemp

# At this point, you could potentially 'rm "$rarFILE"' to delete the original, but
# I'd suggest not doing so until you're certain you've got a good ".zip" file...

done


credit to "Lloyd B." at http://ubuntuforums.org/archive/index.php/t-522660.html.

Saturday, January 08, 2011

Followup on Zellers hours downtown

I spoke to soon in my last post. They seemed to have changed their store hours to closing at 7pm monday to friday, and 6 on saturday and sunday. Kind of disappointing, but there you have it. Understandable, at least for the Bay. Why does everything downtown need to close early though? I understand some businesses exist merely to serve the workers in the area, but what with the MTS Centre and some residential there, you'd think there'd be enough presence for them to at least stay open until 8pm Monday to Saturday. I suppose they didn't really have much sales during the time they were open during the christmas rush and used that as a basis.. but they just opened up. I would like to think they'd give it a bit more time to build up regular customers.

Also, has anyone else noticed the unsynchronized crossing signals for the blind play out "FIGARO" at Portage and Vaughn?

Thursday, January 06, 2011

Telebus

It used to be that you could call Winnipeg Transit Telebus and type in your bus stop number and get the time your bus comes next and all was good. But over the last year they've started putting in little advertisements for their other services like BusTxt (which I, as a Linux using poweruser can not understand) and Twitter (Which I as an intelligent human being have no care for). My problem isn't the advertising per se, it's the fact that I HAVE TO LISTEN TO THE GODDAMN THING. I can't interrupt it, otherwise it will take longer than playing the message. I can't just press the stop number, because it won't let me. It's a cavalcade of FAIL and it infuriates me. I don't care about twitter. I don't care about bustxt. I just want to know when the next bus is coming.. oh look, I missed it because I was too busy trying to find out what time the bus is coming to see that it just came. Who is the genius who set this thing up? Newer Technology always makes things worse. Same thing at the Library. I miss the old winnipeg public library terminals you could telnet into. I hate using the web to get that information. It's so slow. Technology from the 80's is faster. Why is that.