In a directory structure which has multiple subfolders and files in it, some of the file names have the suffix _create
(e.g. java1_create
) and some of them with _bak
(java2_bak
).
I need to rename only the files with suffix _create
as _bak
, so that all the files should have the _bak
suffix.
Is there any command or script to do this?
Best Answer
On Linux, assuming that none of your file names have
_create
inside them (only at the end), you can use therename
utility from the util-linux package, which is installed on all non-embedded Linux systems. Callfind
to execute the command on all files in subdirectories recursively.On Debian and derived distributions (Ubuntu, Mint, …) that ship a Perl script as
rename
, either callrename.ul
instead ofrename
, or replacerename _create _bak
byrename 's/_create$/_bak/'
.