0

Does anyone know how can i remove '@2x~ipad' string from all files name in a directory do that a file named: image@2x~ipad.png will be renamed to: image.png I need to rename all files in a certain directory

Can I do it with a loop from terminal? any idea?

  • i've always just used a perl script call chcase, that allows you to use regular expressions to rename files -- http://www.primaledge.ca/chcase.html – Doon Mar 20 '13 at 18:38
  • 1
    You might want to check out some [previous](http://stackoverflow.com/questions/102083/whats-the-best-tool-to-find-and-replace-regular-expressions-over-multiple-files) [questions](http://stackoverflow.com/questions/529345/best-way-to-do-a-find-replace-in-several-files) about this. – summea Mar 20 '13 at 18:40

1 Answers1

1

Using bash (in the terminal):

for file in *2x~ipad.png; do
  mv $file ${file%%\@2x~ipad.png}.png
done
GoZoner
  • 67,920
  • 20
  • 95
  • 145