From 45e08a732f27e1a5f728a2f8fafb3f8eddd95251 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 1 Apr 2020 15:27:44 -0700 Subject: helper for renaming files with extensions --- bin/fix_extensions.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 bin/fix_extensions.sh (limited to 'bin') diff --git a/bin/fix_extensions.sh b/bin/fix_extensions.sh new file mode 100755 index 0000000..e3ddd67 --- /dev/null +++ b/bin/fix_extensions.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +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 -- cgit v1.2.3