Skip to content

assign finder

Sean Akahane-Bryen edited this page Dec 31, 2020 · 2 revisions

Assign UIDs to Finder selection

assign-finder.kmmacros

Appends new UIDs in the pattern (YYYYMMddHHmm) to the names of the files and/or folders selected in Finder.

This macro uses a global Keyboard Maestro variable, Last UID, shared with a number of other macros in this repository so that UIDs assigned in rapid succession (more than one in a given clock minute) don't clash.

Invoked Shell Script

if [[ -d "$KMVAR_Instance_Files" ]]; then
	f="${KMVAR_Instance_Files%/}"
	mv "$KMVAR_Instance_Files" "$f ($KMVAR_Last_UID)/"
else
	extension="${KMVAR_Instance_Files##*.}"
	f="${KMVAR_Instance_Files%.*}"
	mv "$KMVAR_Instance_Files" "$f ($KMVAR_Last_UID).$extension"
fi

Changelog

Version Date Changes
1.07 2020-12-31 Replace YYYY with yyyy in ICU date-time pattern
1.06 2020-07-27 Rename to assign-finder
1.05 2020-07-24 Remove default triggers; use simpler macro names
1.04 2020-07-23 Use consistent variable names
1.03 2020-07-23 Allow UIDs to be appended to folders as well as files
1.02 2020-07-14 Save only most recent UID to Last UID
1.01 2020-07-13 Remove unnecessary braces
1.00 2020-07-08 Initial commit
Clone this wiki locally