Fix comic extension
2 posters
Page 1 of 1
Fix comic extension
I am requesting that comictagger be given an optional feature to automatically fix misnamed extensions and standardise case on comics as it sees them.
Examples:
cbr which is actually a zip would be auto renamed to cbz
CBZ be lower cased to cbz
etc
Examples:
cbr which is actually a zip would be auto renamed to cbz
CBZ be lower cased to cbz
etc
anomander- Posts : 74
Join date : 2013-03-28
Re: Fix comic extension
Not a bad feature if I ever get around to it.
In the meantime, here is a bash script that does what you want:
In the meantime, here is a bash script that does what you want:
- Code:
#!/bin/bash
# A script to fix CBR/CBZ filename extensions that might be mislabeled
# (Also make the extensions all lowercase)
#---------------------------------------------------------------------------
function fix_one_file
{
F=$1
if [ ! -e "$F" ]
then
echo "File doesn't exist!"
exit
fi
ISZIP=`file "$F" |grep "Zip archive data"`
ISRAR=`file "$F" |grep "RAR archive data"`
EXT="${F##*.}"
EXT_LOWER=`echo $EXT | tr '[:upper:]' '[:lower:]'`
if [ "$EXT_LOWER" != "cbz" -a "$EXT_LOWER" != "cbr" ]
then
echo File is not labeled as cbz or cbr.
exit
fi
if [ "$ISZIP" != "" ]
then
if [ "$EXT" != "cbz" ]
then
NEW_EXT=cbz
fi
elif [ "$ISRAR" != "" ]
then
if [ "$EXT" != "cbr" ]
then
NEW_EXT=cbr
fi
else
echo "Not a RAR or Zip archive!"
exit
fi
if [ "$NEW_EXT" != "" ]
then
NEWNAME=`basename "$F" .$EXT`.$NEW_EXT
mv "$F" "$NEWNAME"
echo "New extension is .$NEW_EXT"
else
echo "Current extension (.$EXT) is good."
fi
}
#---------------------------------------------------------------------------
if [ $# == 0 ]
then
echo "Usage: $0 [COMIC FILE LIST]"
echo "Fix the extension on improperly named CBZ and CBR files"
exit
fi
# iterate over all args
IFS=$'\n'
for i in $*
do
echo "$i: "`fix_one_file $i`
done
Re: Fix comic extension
It simply didnt occur to me to use "file". Elegant.
I have been using Perl and some logic around this "read (DATA, $data, 2);"... "if($data eq "PK") {" etc
Its pretty fast and because its Perl cross platform capable. Still all things scripting are beyond (or at least beyond the comfort level) of most users. Maybe not the ones that we have here yet but certainly most of the potential users.
Give it a ponder.
I have been using Perl and some logic around this "read (DATA, $data, 2);"... "if($data eq "PK") {" etc
Its pretty fast and because its Perl cross platform capable. Still all things scripting are beyond (or at least beyond the comfort level) of most users. Maybe not the ones that we have here yet but certainly most of the potential users.
Give it a ponder.
anomander- Posts : 74
Join date : 2013-03-28
Similar topics
» No comic archives were found
» Woes of being a Mac comic user
» That file doesn't appear to be a comic archive?
» Transforms - fixes for common differences between local filename and Comic Vine
» Woes of being a Mac comic user
» That file doesn't appear to be a comic archive?
» Transforms - fixes for common differences between local filename and Comic Vine
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|