Last active
July 4, 2021 20:34
-
-
Save towfiqpiash/8cb619dbe03f52106a2503f8d568e493 to your computer and use it in GitHub Desktop.
Run this shell script to organize files into separate folders
This file contains 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 | |
folders='Compressed Documents Images Music Programs Videos' | |
ext_comp="*.zip *.tar.gz *.tgz *.rar *.7z" | |
ext_doc="*.htm* *.php *.txt *.css *.doc* *.pdf *.PDF *.ppt* *.js *.csv" | |
ext_font="*.ttf" | |
ext_img="*.jp*g *.JPG *.png *.gif" | |
ext_music="*.mp3 *.aac *.wma" | |
ext_progrm="*.deb *.exe *.run *.sh" | |
ext_vid="*.mp4 *.mkv *.flv *.avi *.webm *.wmv" | |
for folder in $folders | |
do | |
if [ $folder == 'Compressed' ] | |
then | |
mkdir -p $folder | |
mv $ext_comp $folder 2>/dev/null | |
elif [ $folder == 'Documents' ] | |
then | |
mkdir -p $folder | |
mv $ext_doc $folder 2>/dev/null | |
elif [ $folder == 'Fonts' ] | |
then | |
mkdir -p $folder | |
mv $ext_font $folder 2>/dev/null | |
elif [ $folder == 'Images' ] | |
then | |
mkdir -p $folder | |
mv $ext_img $folder 2>/dev/null | |
elif [ $folder == 'Music' ] | |
then | |
mkdir -p $folder | |
mv $ext_music $folder 2>/dev/null | |
elif [ $folder == 'Programs' ] | |
then | |
mkdir -p $folder | |
mv $ext_progrm $folder 2>/dev/null | |
elif [ $folder == 'Videos' ] | |
then | |
mkdir -p $folder | |
mv $ext_vid $folder 2>/dev/null | |
else | |
echo "$(tput setaf 3)Problem creating folder..$(tput sgr0)" | |
fi | |
done | |
echo "$(tput setaf 2)Successfully organized..$(tput sgr0)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment