Skip to content

Commit

Permalink
rewritten detoxification
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Oscadal committed Jan 31, 2013
1 parent 45da8fc commit a197214
Showing 1 changed file with 19 additions and 49 deletions.
68 changes: 19 additions & 49 deletions detoxify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,71 +9,41 @@
# OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.
# See the GNU General Public License for more details.


# check syntax
if [ $# -eq 0 ]
then
echo -e "\nFix filenames recursively.\n\nSyntax: $(basename $0) <folder>\n"
exit 1
echo -e "\nFix filenames recursively.\n\nSyntax: $(basename $0) <folder>\n"
exit 1
else
if [ -n "$1" ]
then
if [ -d "$1" ]
then
cd "$1" 2>/dev/null
if [ $? -ne 0 ]
then
exit 1
fi
else
echo "Invalid folder: $1"
exit 1
fi
fi
if [ -n "$1" ]
then
if [ -d "$1" ]
then
echo "Processing folder: $1"
else
echo "Invalid folder: $1"
exit 1
fi
fi
fi

# check for installed app
which detox >/dev/null 2>&1
if [ $? -eq 1 ]
then
echo "Installing detox package..."
sudo apt-get install detox
echo "Installing detox package..."
sudo apt-get install detox
fi
which detox >/dev/null 2>&1
if [ $? -eq 1 ]
then
echo "Detox is not installed!"
exit 1
echo "Detox is not installed!"
exit 1
fi

# recurse any folders and execute detox 1st round
for i in *
do
if [ -d "$i" ]
then
echo "Recursing into directory: $i"
$0 "$i"
fi
if [ -f "$i" ]
then
detox -s utf_8 "$i" >/dev/null 2>&1
fi
done

# recurse any folders and execute detox 2nd round
for i in *
do
if [ -d "$i" ]
then
echo "Recursing into directory: $i"
$0 "$i"
fi
if [ -f "$i" ]
then
detox -s lower "$i" >/dev/null 2>&1
fi
done

# execute detox
detox --special --remove-trailing -r -v -s utf_8 "$1"
detox --special --remove-trailing -r -v -s lower "$1"
sync

echo -e "\nDone.\n"
Expand Down

0 comments on commit a197214

Please sign in to comment.