-1

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
DroidOS
  • 8,530
  • 16
  • 99
  • 171

1 Answers1

1

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/" ./*

user156213
  • 736
  • 4
  • 12