aboutsummaryrefslogtreecommitdiffstats
path: root/bin/fix_extensions.sh
blob: 9f6113c2afccaa32fa1edf862eaaa7c4f7937ef2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash

# Tiny helper to rename files based on their detect mimetype.
#
# Call with no trailing slash like:
#
#   ./bin/fix_extensions.sh some_dir

for file in $1/*; do
    TYPE=$(file --mime-type -b "$file" | cut -f2 -d/);
    if [[ ! $file =~ \.$TYPE ]]; then
        mv -v "$file" "$file.$TYPE";
    fi
done