organize
organize copied to clipboard
Passing arguments in Automator
The idea here is to to apply a rule to a folder of choice by right-clicking the folder (or selecting the files and right-clicking) and choosing the organize
action (which would include a specific --config-file=<>
).
So the question is how to pass the specified folder or files
arguments onto organize
? Is there a way we can specify this in the config file
? This would prove really useful to organize
certain folders on the spot.
Thanks in advance!
That's an interesting use-case! I haven't worked with Automator much so far but it should be possible to define environment variables? If this is the case then you should be already able to use environment variables as folders:
rules:
- folders: $MY_FOLDER
actions:
- echo: "{path}"
And call it with MY_FOLDER="~/Desktop" organize sim
Thanks, @tfeldmann! I have been trying this approach with automator but I'm failing to pass the arguments to organize
. Probably a minor coding issue. Will let you all know when I manage to make it work as it would be very useful :)
Any updates on this?
Hi there! And thanks for asking.
Unfortunately, I haven't managed to make it work (even after last upgrade).
As I mentioned above, the idea is to create an Automator shell script that then I can call from any folder with a mouse click or key shortcut. The Automator shell script receives current "files or folders" and passes input "as arguments". It contains the following:
export PATH=/usr/local/bin:$PATH
MY_FOLDER="$@"
organize --config-file=/path/to/config.yaml run
The YAML config file defines folder as this:
- folders: $MY_FOLDER
However, when I call this from a folder, nothing happens (it is supposed to sort file types into subfolders).
Got it working!

Automator shell script:
export PATH=/usr/local/bin:~/.local/bin:$PATH
MY_FOLDER="$@"
organize run ~/Dropbox/Apps/organize/finder-action.yml --working-dir="$MY_FOLDER" > $MY_FOLDER/organize.txt
This uses the new working-dir
argument. In your config you then use .
as location, no need for env variables:
rules:
- locations: "."
filters:
- name: "test-trash-this-file"
actions:
- trash
In the organized folder you will find a organize.txt
for debugging. You can disable this in the shell script.
The automator action:
EDIT: Make sure your config file is not on the desktop, I got permission errors there. Putting it into dropbox works fine for me.
Hey! Just wanted to drop a quick note to say thanks for your response to this issue. It's been a busy time on my front but finally got around to trying your solution, and it worked like a charm!