Issue
I have a folder containing a sequence of files whose names bear the form filename-white.png
. e.g.
images
arrow-down-white.png
arrow-down-right-white.png
...
bullets-white.png
...
...
video-white.png
I want to strip out the -white
bit so the names are simply filename.png
. I have played around, dry run with -n
, with the Linux rename
command. However, my knowledge of regexes is rather limited so I have been unable to find the right way to do this.
Solution
If you are in the directory above images, the command is
rename "s/-white.png/.png/" images/*
If your current directory is images
, then run rename "s/-white.png/.png/" ./*
instead. To do a dry run, just attach a -n
like you said:
rename -n "s/-white.png/.png/" images/*
or
rename -n "s/-white.png/.png/" ./*
Answered By - user156213