Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Alameda

macrumors 6502a
Original poster
Jun 22, 2012
763
250
Whenever my teenage daughter uses my Mac (a MBA running Mountain Lion), she visits Tumblr and downloads dozens of jpg and png files to my Desktop. So I told her not to, all to no avail.

So I turned to Automator. I created a Folder Action, and the purpose of the folder action is to automatically move all image files to a sub-folder of My Documents, unless the file name begins with "Screen" (If I take a screenshot, I want to keep it on the Desktop). It works! Well, sometimes it works, and sometimes it does not. Most aggravating! Since it works, I can't figure out what I'm doing wrong, but since it doesn't always work, I must be doing something wrong.

(By the way, I'm fine with doing this a different way).
What I did was create a Folder Action for the Desktop Folder (not sub-folders). It goes like this:

Filter Finder Items where:
Name does not contain Screen
Kind is image or
Kind is Web Internet location
Move (these) Finder Items to the sub-folder

It's installed as a "Folder Action." It works, but only sometimes.
 

chown33

Moderator
Staff member
Aug 9, 2009
9,904
6,897
Beyond the pale
It might be simpler to create an account of her own, where she can muck up the Desktop as she wants.

To ensure she uses her account, change the password on your account, and also enable the Require Password for when waking from sleep or screensaver. Those settings are in System Preferences > Security & Privacy.
 

Alameda

macrumors 6502a
Original poster
Jun 22, 2012
763
250
It might be simpler to create an account of her own, where she can muck up the Desktop as she wants.

To ensure she uses her account, change the password on your account, and also enable the Require Password for when waking from sleep or screensaver. Those settings are in System Preferences > Security & Privacy.
Thanks, I appreciate the help. But there will still be 1,000 icons on her desktop. Automator should work; I want to find out why it doesn't, or else what other type of script I can write that will do the job.

Can't I just put a simple Shell script on Chrontab or something like that?
 

chown33

Moderator
Staff member
Aug 9, 2009
9,904
6,897
Beyond the pale
Thanks, I appreciate the help. But there will still be 1,000 icons on her desktop.

That's her problem, not yours. When she clutters your desktop, you have to clean it up. When she clutters her own desktop, you don't have to do anything, except maybe tell her it's her problem to solve.

If the files are on her Desktop because the download folder is set to Desktop, you could change the download folder to something other than Desktop.

Automator should work; I want to find out why it doesn't, ...
You'll have to come up with a repeatable fail case, or figure out some way of logging everything that happens, and then you'd look at the log after it doesn't work. I'm not aware of any "logging" action in Automator, but I'm not an expert in Automator.

I agree with you, Automator should work. But you haven't told us what happens when it doesn't work. That is, you expected X to happen, and Y actually happened. We don't know exactly what X or Y are. All you've said is that sometimes it doesn't work, without ever describing what "doesn't work" actually means. For example, are some files not moved, or is it an all-or-nothing failure: either all files are moved, or no files are moved.

Debugging is careful systematic observation, usually coupled with test cases. So make some test cases, keep careful observations (i.e. write everything down), and when something doesn't work as expected, then post exactly what you expected to happen and what actually happened.

... or else what other type of script I can write that will do the job.

Can't I just put a simple Shell script on Chrontab or something like that?

You may not realize that you can write a shell script inside an Automator action (Run Shell Script), and run that instead of the action that moves the files using the builtin Automator action. This assumes you know how to write a shell script.

No crontab (note spelling) would be needed, if the shell script in the Automator action is working properly.
 

Alameda

macrumors 6502a
Original poster
Jun 22, 2012
763
250
But you haven't told us what happens when it doesn't work. That is, you expected X to happen, and Y actually happened. We don't know exactly what X or Y are. All you've said is that sometimes it doesn't work, without ever describing what "doesn't work" actually means.

You may not realize that you can write a shell script inside an Automator action (Run Shell Script), and run that instead of the action that moves the files using the builtin Automator action. This assumes you know how to write a shell script..
The failure is: Move 10 image files to Desktop, wait a few seconds, and they vanish and reappear in the desired folder. Repeat, (move the same files back) and maybe some move and others don't. Other times, no files move at all.

It may be that my test is wrong: Maybe Automator keeps objects in memory a long time, and so the newly-dropped files are marked as having already been moved. I can test that some more.

But writing a shell script seems like a simple solution. I'll give it a shot and report back.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.