3 # Description: Batch rename selection or current directory with qmv or vidir
6 # - Try to mimic current batch rename functionality but with correct
7 # handling of edge cases by qmv or vidir.
8 # - Qmv opens with hidden files if no selection is used. Selected
9 # directories are shown.
10 # - Vidir don't show directories nor hidden files.
12 # Shell: POSIX compliant
15 selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
17 if type qmv >/dev/null 2>&1; then
18 batchrenamesel="qmv -fdo -da"
19 batchrename="qmv -fdo -a"
20 elif type vidir >/dev/null 2>&1; then
21 batchrenamesel="vidir"
24 printf "there is not batchrename program installed."
28 if [ -s "$selection" ]; then
29 printf "rename selection? "
33 if [ "$resp" = "y" ]; then
34 # -o flag is necessary for interactive editors
35 xargs -o -0 $batchrenamesel < "$selection"
38 if [ -p "$NNN_PIPE" ]; then
39 printf "-" > "$NNN_PIPE"
41 elif [ ! "$(LC_ALL=C ls -a)" = ".
43 # On older systems that don't have ls -A