How do I rename multiple files at a shell prompt under a Linux or UNIX operating systems? https://www.cyberciti.biz/tips/renaming-multiple-files-at-a-shell-prompt.html #linux #unix #macos #sysadmin #opensource
@nixCraft
* 25-year-old Perl script invoked via a bash alias.

@nixCraft Beware that there are at least two different utilities named "rename". I think the syntax which that image shows for "rename" is the one for the perl utility (which might be what "prename" stands for in the last entry).

The rename utility from util-linux has a different syntax, shown in the linked page.

Which one gets installed as rename may depend on the distro/system.

perl rename: https://www.unix.com/man-page/linux/1/prename/
util-linux rename: https://www.unix.com/man-page/linux/1/rename.ul/

prename(1) [linux man page]

"rename" renames the filenames supplied according to the rule specified as the first argument. The perlexpr argument is a Perl expression which is expected to modify the $_ string in Perl for at least some of the

@nixCraft didnt know rename yet, thx

@nixCraft find + mv + shell parameter expansion + test:
find -mindepth 1 -maxdepth 1 -type f -exec bash -c 'file="{}"; [ "${file}" != "${file//needle/replacement}" ] && mv "${file}" "${file//needle/replacement}"' \;

man find
man mv
man test
https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html

#term_tips

Shell Parameter Expansion (Bash Reference Manual)

Shell Parameter Expansion (Bash Reference Manual)

GitHub - yaa110/nomino: Batch rename utility for developers

Batch rename utility for developers. Contribute to yaa110/nomino development by creating an account on GitHub.

GitHub
@nixCraft I use neovim with dirbuf for mass renaming
@nixCraft use `vifm` and edit it in #VIM MWAhahaha!
@nixCraft ‘vidir’ from moreutils is also great

@nixCraft

for f in * ; do print mv "$f" "$( print "$f" | sed 's///' )" ; done

Fit sed expression to taste and remove first `print' once satisfied

@nixCraft You can try: ls *.bkp | sed 's/\.bkp//' | xargs -I '{}' mv '{}.bkp' '{}'