Created
May 5, 2019 13:52
-
-
Save johnjreiser/5aa1111ce8ae91ecbface367bbde4625 to your computer and use it in GitHub Desktop.
Sort extensionless files by type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TXT="text/plain; charset=us-ascii" | |
PNG="image/png; charset=binary" | |
JPEG="image/jpeg; charset=binary" | |
MOV="video/quicktime; charset=binary" | |
MP4="video/mp4; charset=binary" | |
GPP="video/3gpp; charset=binary" | |
for file in *; do | |
currfile=`file -b -i $file` | |
if [[ "$currfile" == "$JPEG" ]] ; then | |
mv $file ./jpg/ | |
elif [[ "$currfile" == "$MOV" ]] ; then | |
mv $file ./mov/ | |
elif [[ "$currfile" == "$MP4" ]] ; then | |
mv $file ./mp4/ | |
elif [[ "$currfile" == "$GPP" ]] ; then | |
mv $file ./3gpp/ | |
elif [[ "$currfile" == "$PNG" ]] ; then | |
mv $file ./png/ | |
elif [[ "$currfile" == "$TXT" ]] ; then | |
mv $file ./txt/ | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment