Skip to content

Instantly share code, notes, and snippets.

@IDK9911
Last active January 19, 2023 14:43
Show Gist options
  • Save IDK9911/0c319e7e117345043b66abc662d05f56 to your computer and use it in GitHub Desktop.
Save IDK9911/0c319e7e117345043b66abc662d05f56 to your computer and use it in GitHub Desktop.
Setting up an automatic folder action that organizes ur downloads folder. In this, there is drop folder which gets triggered whenever there is transfer of a data of any format.
Preparations:
select a directory(in my e.g its called Organzied)
and open in terminal
mkdir
all_apkg all_audio all_dmg all_img all_json all_pdf all_sh all_txt
all_app all_css all_folders all_ipynb all_mp4 all_pkg all_sql all_xlsx
all_archive all_csv all_html all_js all_odt all_py all_tar all_zip all_compressed
Steps:
1.Open Automator
2.Select folder action
3.Choose a drop folder e.g (Organized_Download)
4.Pase the shell script
5.(optional maybe) Right click on (Organized_Download) and enable Folder action.
Testing:
Test it out, try enable and disable of Folder action setup if isnt working.
How to edit and find:
Goto that folder(Orgnaized_Download) and click on Folder action setup and then click the folder action and u'll see below the
edit workflow and it will open it in automator
#Run shell script in automator and paste this code
shopt -s extglob; #to use regular expressions
echo hello
for f in "$@"
do
echo "$f"
stats=$(echo"")
case $f in
*.dmg)
mv $f ~/Organized/all_dmg;;
*.jpg|*.jpeg|*.png|*.webp)
mv $f ~/Organized/all_img
paths="~/Organized/all_img/";;
*.tar|*.zip)
mv $f ~/Organized/all_archive;;
*.wav|*.mp3)
mv $f ~/Organized/all_audio;;
*.mp4|*.3gp)
mv $f ~/Organized/all_mp4;;
*.bz2|*.gzip)
mv $f ~/Organized/all_compressed;;
*.apkg)
mv $f ~/Organized/all_apkg;;
*.pkg)
mv $f ~/Organized/all_pkg;;
*.json)
mv $f ~/Organized/all_json;;
*.xlsx)
mv $f ~/Organized/all_xlsx;;
*.py)
mv $f ~/Organized/all_py;;
*.html)
mv $f ~/Organized/all_html;;
*.css)
mv $f ~/Organized/all_css;;
*.js)
mv $f ~/Organized/all_js;;
*.sql)
mv $f ~/Organized/all_sql;;
*.odt)
mv $f ~/Organized/all_odt;;
*.pdf)
mv $f ~/Organized/all_pdf
paths="~/Organized/all_pdf/";;
*.app)
mv $f ~/Organized/all_app;;
*.txt)
mv $f ~/Organized/all_txt;;
*)
if [ -d $f ]
then
mv $f ~/Organized/all_folders; else
stats=un
osascript -e "display notification \"Operation ${stats}succesfull ${paths}${f} \" ";
fi;;
esac
done
f=$(basename $f) 2>/dev/null
osascript -e "display notification \"Operations ${stats}succesfully completed ${paths}${f} \" ";
echo "exiting"
@IDK9911
Copy link
Author

IDK9911 commented Jan 19, 2023

image

@IDK9911
Copy link
Author

IDK9911 commented Jan 19, 2023

image

image

See only ipynb is in my drop folder cause i forgot to include it my script.
*.ipynb)
			mv $f ~/Organized/all_ipynb;;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment