Automatically Organize Files With an Automator Folder Action Shell Script

By using a Shell script in an Automator Folder Action you can create a "drop zone" folder that moves any file placed into it. By using a Shell script it is easy to add new conditions and destination folders.



Here’s the script I’m using in the video:

for f in "$@"
do
	DEST=""

	if [[ $f == *"dailyreport"* ]]
	then
		DEST="/Users/macmost/Documents/Daily Reports"
	elif [[ $f == *"tpsreport"* ]]
		DEST="/Users/macmost/Documents/TPS Reports"
	elif [[ $f == *".txt" ]]
		DEST="/Users/macmost/Documents/Text Files"
	fi

	if [[ $DEST != "" ]]
	then
		osascript -e "display notification \"Moved $f to $DEST\""
		mv $f $DEST
	elif
		osascript -e "display notification \"$f Not Moved.\""
	fi
done

Comments: 2 Responses to “Automatically Organize Files With an Automator Folder Action Shell Script”

    Sumanth Kumar
    4 days ago

    Shouldn’t there be ‘then’ after every elif?

    1 day ago

    Sumanth: Not in a shell script. Try it and see.

Leave a New Comment Related to "Automatically Organize Files With an Automator Folder Action Shell Script"

:
:
:
0/500 (500 character limit -- please state your comment succinctly and do not try to get around this limit by posting two comments)