On 25 Nov 14:33, Chris Walker wrote:
On 24/11/11 16:44, Mark Rogers wrote:
On 24/11/11 16:18, Chris Walker wrote:
Fallen at the second hurdle!
Third, or fourth now?
Note I originally said: rename -n "s/.jpg..*$/.jpg/" * which should have been rename -n "s/.jpg..*$/.jpg/" * where the first matched any character which was followed by jpg, where the latter only matches a dot followed by jpg. Again, it's all about trying to make it avoid false positives.
This is still failing with this message :- mv: cannot stat `(3439)/test.jpg;1': No such file or directory
I *think* it's because there are spaces in the directory names. I've been searching all morning for ways round that but without success so far.
is that using rename or using find with a mv?
rename isn't recursive by default so I suggest doing: find . -type f -name '*.jpg.*' -execdir rename 's/.jpg.*$/.jpg/' {} +
Note: if there are 2 files with the same name except the bit after the .jpg, then the second will *not* be renamed and it'll warn you.
I've just tested that on a local set of files where the files and the directories both have spaces in them.
Cheers,