I recently discovered the perl-based
rename function but since I don't know anything about perl I can't use it properly. I found of a lot of question about the subject but nothing helped me.
I would like to rename
filename - y01m01 - extra.log filename - y01m02 - extra.log filename - y01m03 - extra.log ... filename - y05m12 - extra.log
filename-y01m01.log filename-y01m02.log filename-y01m03.log ... filename-y05m12.log
I managed to rename into
filename-y01m01 - extra.log filename-y01m02 - extra.log filename-y01m03 - extra.log ... filename-y05m12 - extra.log
rename 's/filename - y*/filename-y/ *.log but I don't know how to get rid of this
- extra string at the end. The number of characters in
- extra is not fixed and depends on each file so I can't just substitute the eight characters before the extension.
I guess the solution is to substitute everything after the space (and including the space) but I don't know how to code it.
Thank you for your help.