6

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!

  • do you know how to use Automator ? – Ruskes Apr 6 '13 at 20:10
  • Hardly.. I've got one functionality installed A move file extension action, but the problem is: I can't configure the action to be immediate, but only at a specific time.. – Sander Schaeffer Apr 6 '13 at 20:27
4

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

  • You could also save the script with a name that ends with .command Thereby, it is clickable. You can just douleclick on the file and the command will be executed. No more need to type anything in terminal. – Vincent Apr 6 '13 at 20:47
  • And this only searches on desktop, not subfolders right? Since that is what I want: Not search any deeper than ~/desktop, just the desktop 'folder'. – Sander Schaeffer Apr 6 '13 at 21:14
  • So.. I made a document with an .command extension and it does execute the file, though it does not execute the content of the file, since I get an error message 'you do not have enough privileges to execute this file'. (<- My translation of it) If I go to info of the file, it's on 'writable and readable by everyone'. Suggestion? – Sander Schaeffer Apr 6 '13 at 21:24
  • The content of the file is 'cd ~/desktop' 'mv *.png *.jpg ~/desktop/Pictures Saved as 'MovePictures.command' Since I just want it to be executed when clicked – Sander Schaeffer Apr 6 '13 at 21:26
  • As I wrote in my answer, you have to use chmod ugo+x example.command and then it will work! – bluewoodtree Apr 6 '13 at 21:32
2

In Automator do following, Open Automator and select "Services"

Than recreate this for your images files.

Let me know if you have problem.

Save this "Service" and give it a name like "Move images from desktop"

enter image description here

In Finder only select the one(s) on your desktop you want to move, and under Finder select Services and than you will see your service you just made, so select it.

Now every time you want to clean your desktop just to the above. If you want it even faster, you can assign a keyboard short cut for it.

  • Hm, I've got it working, but it also searches in subfolders. I do not want that. Any solution for that..? – Sander Schaeffer Apr 6 '13 at 21:13
  • So it is moving the files you selected on Desktop to where you wanted them!, let me check on your sub folder comment. – Ruskes Apr 6 '13 at 21:16
  • Maybe you try the Terminal commands solution below, while I look at the issue. – Ruskes Apr 6 '13 at 21:17
  • Yes, it moves files on the desktop, but also subfolders, so I got it working, but the action needs to be limited.. – Sander Schaeffer Apr 6 '13 at 21:17
  • 1
    [IMG]i45.tinypic.com/2uq2kja.png[/IMG] I hope you understand it enough, since it's dutch. Anyway, I've made a service, 'Receives selected files or folders in 'Finder' Search in 'Desktop' One or more from next criteria Extension contains JPG Extension contains PNG And step by step, it results in also searching in subfolders.. – Sander Schaeffer Apr 6 '13 at 21:33
2

Hazel is what you want.

It's like Mail.app rules or Gmail filters, except for your files.

Here's an example rule that will do what you're looking for in the first set

It costs $25. It's worth that much and more. If you value your time at $5/hour this app will pay for itself and increase your satisfaction with your Mac usage.

It's basically a servant in app form. :-)

There's a 14-day free trial, and the developer is extremely responsive. Your money will go to help support a great Mac app that does something incredibly well. Actually, it does lots of things incredibly well.

(Note: I have absolutely no connection to this app or its developer except being a huge fan.)

Yes, you could write your own shell script or AppleScript to do this with launchd. I could do it faster than you could, because I've done it before. But I bought Hazel. Why? Because it's the best solution. And once you start using it, you will find so many different uses for it, you'll be glad to have it.

Seriously I can't use a Mac without this anymore.

What you can search for:

Here are the "attributes" you can search for:

("Kind" is thing like "image" or "document" or "folder".)

You can setup multiple criteria per folder, and you can set the precedence as to which rules run in which order.

What you can do for matching files:

Here are the actions that you can take on a file which matches those attributes:

Download the demo and start using it, and in two weeks I bet you won't want to give it up.

Examples

Here are some things that I do with Hazel:

  1. When a new .zip arrives in my ~/Downloads/ folder, I automatically open it with The Unarchiver which unzips it to ~/Actions/Unzip/

  2. Hazel looks in ~/Actions/Unzip/ for files which end with .app and if it finds any, it moves them to /Applications/

  3. .pkg files? Hazel opens the Installer app

  4. .dmg? Hazel mounts it

  5. .pdf? Hazel moves it to ~/Dropbox/Documents/Downloads/ and then opens it

  6. Image? Hazel moves it to ~/Dropbox/Photos/

  7. New .amz file in ~/Downloads/? Hazel moves it to ~/Music/ and then runs clamz on the file

  8. new PDF in ~/Actions/OCR/? Hazel opens it in ABBYY FineReader

  9. New file in ~/Actions/ToAir/? Hazel will scp the file/folder to my MacBook Air from my iMac and then move the file to another folder when it is done. (Ditto on my MacBook Air if if put a file into ~/Actions/ToiMac/)

  10. I have Drafts setup on my iOS devices setup to save snippets as text files in specific folders to trigger actions on my remote Macs. For example, any new text file in: ~/Dropbox/wget/ gets processed with wget so I can download files from my iOS devices to my Dropbox.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .