Rename recursively
How could I rename (lots of) files (recursively from the pwd) from *.jpg to cover.jpg? I have many different cover art files for my mp3s, but I want to rename them all to cover.jpg (in each folder). Thanks!
|
Quote:
|
Hi,
for THISFILE in `find /mp3/base/dir/ -type f -name "*.jpg"`; do echo ${THISFILE} ${THISFILE%/*}"/cover.jpg"; done This looks for jpg files in /mp3/base/dir/ (substitute with your mp3 base directory) and renames them to cover.jpg If there are more the one jpg files in the same directory all will be renamed to cover.jpg and you will end up with 1 jpg file!! I do assume that all jpg's are in seperate dirs (one jpg per album). I also assume that you have a base directory for mp3's. Something like this (names may differ): /multimedia/mp3 /multimedia/mp3/Bauhaus /multimedia/mp3/Japan If a test run succeeds, change echo to mv. Hope this helps. |
Hi,
Quote:
The thread you refer to changes JPG to jpg, which is easier then changing xxxx.jpg to cover.jpg. |
Quote:
Pleasant day, Bob |
Quote:
|
Hi,
Did you try my command? It should pick up on the dot files as well: Code:
/tmp/Temp $ ls -lAR Hope this helps. |
Quote:
try Code:
shopt -s dotglob |
Yes, druuna, you are right. I'm sorry. I did not see the hidden files in the list. There is however a catch. When I use echo, no problem. When I replace it with mv, it says cannot stat, probably because there are spaces in the folder names. Can that be an issue?
|
Quote:
Code:
for THISFILE in `find /tmp/Temp/ -type f -name "*.jpg"`; do echo "${THISFILE}" "${THISFILE%/*}/cover.jpg"; done |
Hi,
A possible solution for the spaces would be to change this: echo ${THISFILE} ${THISFILE%/*}"/cover.jpg" into: echo "${THISFILE}" "${THISFILE%/*}/cover.jpg" Hope this helps. Beaten by The Tinkster ;) |
All times are GMT -5. The time now is 02:32 PM. |