Set custom Automator params:
- Workflow receives current «files or folders» in «Finder»
- Add action: Run Shell Script
- Pass input: as arguments
for f in "$@"
do
# If user right-clicked a file, use its parent folder
if [ -f "$f" ]; then
dir="$(dirname "$f")"
else
dir="$f"
fi
# Create a new untitled file safely
newfile="$dir/NewFile.txt"
n=1
while [ -e "$newfile" ]; do
newfile="$dir/NewFile $n.txt"
((n++))
done
touch "$newfile"
done
macOS custom quick actions (ie “New File”)
Tags: