How to automaticly move every file on desktop to specific folder based on extension

desktopfolderssmart-folders

I'm looking for something, probably some kind of action script, that will at any time move everything that's on my desktop directly to a specific folder on my desktop, based on the extension. Just to prevent cluttering.

Some examples I want:

  • Folders: Do not move
  • .PSD/.Ai/.INDD (all Adobe workfiles) -> Move to -> ~/Desktop/Workfiles
  • .PNG/.JPG (etc., All picture files) -> Move to -> ~/Desktop/Pictures
  • .doc(x)/.xls/.pdf (all document files) -> Move to -> ~/Desktop/Documents

Others I guess I can do myself based on the how-to for above.

I hope someone could help me with this! Any action script/Mac functionality/3rd party app (free/paid) that does this is acceptable, with the only minimum requirement the check and move of files must be directly/every 30 mins (at max)

Thanks!

Best Answer

You can do this in the terminal (shell). Open the terminal and type cd ~/Desktop to change you current working directory to the Desktop.

Then for the different cases you listed:

mv *.PSD *.Ai *.INDD ~/Desktop/Workfiles

mv *.PNG *.JPG ~/Desktop/Pictures

mv *.doc *docx *.xls *.pdf ~/Desktop/Documents

mv file target is the command to move files. You can move multiple files at once: mv file1 file2 file3 target. The asterisk * is the so-called wild card character. So * stands for every character or character sequence. *.doc would mean that it would affect all files that end with .doc. You could also do it other way around, e.g., A* to affect all files that start with A.

If you want, you can copy the following lines into an empty text file and save it as example.sh and add #!/bin/bash to the first line. Make it executable by typing chmod ugo+x example.sh. Then, you can use it every time you want to move your files from your desktop by typing ./example.sh in the shell from your desktop.

So the suggested script contents would could look like this:

#!/bin/bash

cd ~/Desktop

mv *.PSD *.Ai *.INDD ~/Desktop/Workfiles
mv *.PNG *.JPG ~/Desktop/Pictures
mv *.doc *docx *.xls *.pdf ~/Desktop/Documents

As mentioned in the comments, you can save it as example.command and use chmod ugo+x to make it clickable and executable