Last active
January 19, 2023 14:43
-
-
Save kazimmsyed/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.
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
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 |
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
#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" |
Author
kazimmsyed
commented
Jan 19, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment