My build of nnn with minor changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env sh
  2. # Description: Batch rename selection or current directory with qmv
  3. #
  4. # Notes:
  5. # - Try to mimic current batch rename functionality but with correct
  6. # handling of edge cases by qmv or vidir.
  7. # Qmv opens with hidden files if no selection is used. Selected
  8. # directories are shown.
  9. # Vidir don't show directories nor hidden files.
  10. #
  11. # Shell: POSIX compliant
  12. # Author: José Neder
  13. selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
  14. if command -v qmv >/dev/null 2>&1; then
  15. batchrenamesel="qmv -fdo -da"
  16. batchrename="qmv -fdo -a"
  17. elif command -v vidir >/dev/null 2>&1; then
  18. batchrenamesel="vidir"
  19. batchrename="vidir"
  20. else
  21. printf "there is not batchrename program installed."
  22. exit
  23. fi
  24. if [ -s "$selection" ]; then
  25. printf "rename selection? "
  26. read -r resp
  27. fi
  28. if [ "$resp" = "y" ]; then
  29. # -o flag is necessary for interactive editors
  30. xargs -o -0 $batchrenamesel < "$selection"
  31. elif [ ! "$(LC_ALL=C ls -a)" = ".
  32. .." ]; then
  33. # On older systems that don't have ls -A
  34. $batchrename
  35. fi