Home / Mac / Organize files automatically with an automation folder shell script

Organize files automatically with an automation folder shell script



Using a Shell script in an Automator folder action, you can create a “drop zone” folder that moves a file located in it. Using a Shell script makes it easy to add new conditions and destination folders.




Here is the script I use 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

Source link