mirror of
https://github.com/jarun/nnn.git
synced 2024-11-05 02:43:12 +00:00
3bd115ef93
* change version checks to `which` instead. add comments around imvr in linux * add which checks for renamer and preview-tui as well
42 lines
1 KiB
Bash
Executable file
42 lines
1 KiB
Bash
Executable file
#!/usr/bin/env sh
|
|
|
|
# Description: Batch rename selection or current directory with qmv
|
|
#
|
|
# Notes:
|
|
# - Try to mimic current batch rename functionality but with correct
|
|
# handling of edge cases by qmv or vidir.
|
|
# Qmv opens with hidden files if no selection is used. Selected
|
|
# directories are shown.
|
|
# Vidir don't show directories nor hidden files.
|
|
#
|
|
# Shell: POSIX compliant
|
|
# Author: José Neder
|
|
|
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
|
|
|
if which qmv >/dev/null 2>&1; then
|
|
batchrenamesel="qmv -fdo -da"
|
|
batchrename="qmv -fdo -a"
|
|
elif which vidir >/dev/null 2>&1; then
|
|
batchrenamesel="vidir"
|
|
batchrename="vidir"
|
|
else
|
|
printf "there is not batchrename program installed."
|
|
exit
|
|
fi
|
|
|
|
if [ -s "$selection" ]; then
|
|
printf "rename selection? "
|
|
read -r resp
|
|
fi
|
|
|
|
if [ "$resp" = "y" ]; then
|
|
# -o flag is necessary for interactive editors
|
|
xargs -o -0 $batchrenamesel < "$selection"
|
|
elif [ ! "$(LC_ALL=C ls -a)" = ".
|
|
.." ]; then
|
|
# On older systems that don't have ls -A
|
|
$batchrename
|
|
fi
|
|
|