0

I'm trying to use the rename function, supplied as part of cygwin, unix-utils ( Mar22 2015), and it does not function as advertised.

All the examples I've seen indicate this to be the syntax:

rename 's/old pattern/new pattern' *.txt

This is supposed to replace ALL occurrences of file names, containing the old pattern, with the new name, using the new pattern but, instead, it does nothing. Literally. No syntax error. No warning. I enter the command; the command is executed; and the prompt re-appears, but nothing happened. I'm replacing dashes with spaces, so I thought I may need to use an escape character, but it didn't have any effect.

This code works, but only for ONE occurrence of the pattern:

rename "old pattern" "new pattern" *.txt

Am I using the latest version of rename? Is there another command I can use? I am renaming files using "-" instead of spaces, so having to put rename into a loop just to get rid of 1 to 10 dashes in hundreds of files, is really, really lame.

As always your help would be greatly appreciated.

Tony

1
  • rename --version and man rename should give you some good information.
    – pak
    Mar 3, 2016 at 3:12

1 Answer 1

0

$ touch mickey\ mouse01 mickey\ mouse02 mickey\ mouse03

$ ls

'mickey mouse01' 'mickey mouse02' 'mickey mouse03'

$ rename mickey\ mouse mickey_mouse mickey\ mouse*

$ ls

mickey_mouse01 mickey_mouse02 mickey_mouse03

1
  • gahhk... It certainly works now. I must be going blind...
    – C0ppert0p
    Mar 24, 2016 at 23:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .