On 25 Nov 15:36, Chris Walker wrote:
On 25/11/11 15:14, Brett Parker wrote:
On 25 Nov 14:33, Chris Walker wrote:
Third, or fourth now?
is that using rename or using find with a mv?
that's using find with 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.
Some files here have spaces in the name and so do virtually all the directories. I've run that command with slight modifications (I'll explain that) and although it runs and doesn't exhibit any errors, it also doesn't rename the files.
The modifications are because the files are not named test.jpg.;1, they're named test.jpg;1 so I changed the command to find . -type f -name 'test.jpg;1' -execdir rename 's/.jpg;1$/.jpg/' {} +
I then modified it some more so that it then looked like this find . -type f -name 'test.jpg;1' -execdir rename 's/\test.jpg;1$/test.jpg/' {} +
But that also fails to do anything. Is there any other way for me to find out why it's failing? Can I run bits of the command and then add on bits to refine the testing?
Can I thank you for being so patient.
OK - so, here we go...
$ find . . ./d space ./d space/c space .jpg;1 ./d space/d space .jpg;1 ./c space ./c space/b space .jpg;1 ./c space/a space .jpg;1 $ find . -type f -name '*.jpg*' -execdir rename 's/.jpg.*$/.jpg/' {} + $ find . . ./d space ./d space/c space .jpg ./d space/d space .jpg ./c space ./c space/b space .jpg ./c space/a space .jpg $
Now, that looks to work to me... but maybe I'm missing something.