Automator -> New Quick Action
Workflow receives current files or folders in any application
Image: Documents
Get Selected Finder Items
Run Shell Script Shell: /bin/zsh - Pass Input: as arguments
for fullpath in "$@"
do
filename="${fullpath##*/}"
newname="$(echo "$(date '+%s')""$(jot -r 1 100 999)")"
dir="${fullpath%$filename}"
base="${filename%.[^.]*}"
ext="${filename:${#base} + 1}"
dext=$(echo $filename | grep -E -o '\.[^.]*\.[^.]*$')
if [[ $ext == "" ]]; then
ext=""
else
if [[ $dext == "" ]]; then
ext=".${filename:${#base} + 1}"
else
ext=$dext
fi
fi
echo -e "$fullpath:\n\tdir = \"$dir\"\n\tbase = \"$base\"\n\text = \"$ext\"\n\tdext = \"$dext\""
echo mv "$fullpath" "$dir$newname$ext"
mv "$fullpath" "$dir$newname$ext"
sleep 0.1
done
Right-click on a file, folder, a group of files or folders in Finder and select Auto Filename
Result:
1690136465531/
1690127110871.gif
1690126366780.warc
1690126824152.webm
1690126824176.mp4
1690136421367.client.secret
1690126366822.png
1690126366733.png
1690126367657.png
1690126367316.png
1690126366368.png
1690126365536.jpg
1690126366542.jpg
1690126515664.jpg
1690124145815.tar.gz
1690126367573.gif
1690126366961.gif
1690126366437.gif