Automatically assigning decimals inside your notes and files

Has anyone figured out how to do that? I think it’s a matter of a pretty simple code which identifies the number of the area, category, and then the file ID under the new file, but I am not skilful enough to make it. Does anyone know of such a plugin for Obsidian and a program for basic files on a Mac?

Not specifically, but some options:

  • write an Alfred workflow
  • write an Automator script and add it to the quick actions
  • write a shortcut and add it to the share menu (Ventura feature)
  • use

From the script perspective, something like a bash script that uses find to find the last number might work (assuming AC.ID file prefix)

# find the last file in the current directory starting with an AC.ID - e.g “./01.01 my file.txt”
lastFile=$(find ./ -maxdepth 1 -regex’./\d\d\.\d\d.*’ | sort -nr | head -1)

nextid=$(($id + 1))
mv “$1” “$ac.$nextid $1”

Writing something more robust in a real language would likely be better, but that would work many places. You probably need to iterate on multiple files and correct the directory to make this work.

Some actual working code for this rather than pseudo code above.

folder=$(dirname "$1")

# find the last file or folder in the current directory
# that starts with an AC.ID - e.g “./01.01 my file.txt”
# or './01.01 some folder name' intentionally ignores
# AC.91 - AC.99 as often these are archive folders
lastFile=$(find -E "$folder" -depth 1 \
    -regex "\./[0-9][0-9]\.[0-8][0-9] .*" \
    | sort -nr | head -1)

# get the AC and ID from the filename. Assumes two characters
# variable indexing is 0 based, so character 2 and 5 are the 3rd
# and 6th characters of the filename (e.g. './01.01 filename')
nextid=$(($id + 1))
# move the file (be verbose + don't overwrite)
mv -nv “$1” “$ac.$nextid $1”