directory based sort using custom property #2207
-
|
I have read wiki and found https://github.com/gokcehan/lf/wiki/Tips#sorting-files-by-a-custom-method But can't implement the solution for my use-case. I want to sort file ONLY inside "~/Music/ARTIST/ALBUM/*" and custom property is "track id" I managed to extract "track id" using ffprobe: https://stackoverflow.com/a/79601915/12038199 ffprobe -v quiet -print_format json -show_format input.mp3 | jq -r '.format.tags.track'Also I'm a bit confused can I only have single custom property? What if I will want to have another custom property for other dir/path or for all paths? setlocal ~/Music/**/**/ set info size # does this work? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
|
Hello @omnigenous! There are two answers for your questions:
# Default `info` setting for every dir unless explicitly specified
set info perm:user
# Specifically override `info` for "Music"
setlocal ~/Music info custom
# Sort by `custom` (track id) inside "Music" only
setlocal ~/Music sortby customNote You could set
To have a different Something like this: cmd on-load &{{
dir="$(dirname "$1")"
cd "$dir" || exit 1
cmds=""
case "$dir" in
# Wildcards are working here
"$HOME"/Music*)
# Music logic
for f in "$@"; do
track=$(ffprobe -v quiet -print_format json -show_format "$f" \
| jq -r '.format.tags.track // empty' 2>/dev/null)
# Chain calls to set `custom` (more efficient than executing each one individually)
cmds="${cmds}addcustominfo \"$f\" \"${track:-}\"; "
done
;;
*)
# Default logic
;;
esac
# Execute remote command if there are any commands to execute
if [ -n "$cmds" ]; then
lf -remote "send $id :$cmds"
fi
}} |
Beta Was this translation helpful? Give feedback.
Hello @omnigenous!
There are two answers for your questions:
infoproperties per directory like this (no wildcards possible):Note
You could set
infoandsortbyinside on-load if you really want to use wildcards for it.customproperty. It can either be shown or hidden and it can either be empty or not empty (it can even be set but also be hidden to only have custom sorting without changing the looks ofinfo).To have…