PDA

View Full Version : mv *.png files to cover.jpg



jort
3rd April 2006, 07:30 PM
Hello,

I have a mt-daap daemon running on Fedora Core 5. This is a daemon which "imitates" a "shared library" from iTunes. So, I have my Fedora machine stuffed with music and can acces to it from my iBook which is the computer I use on daily basis.
Mt-daapd has a feature which is pretty cool. When there is a file called "cover.jpg" in the directory of the file which is being streamed (sent to my iBook), iTunes will display the cover art of the album. That's pretty cool in combination with Front Row you know!

That's enough for the part which I described what lovely feature it would be able to give me.

Well, I have run a script with amaroK which automatically got all the cover art for every album I have in my music collection. This script has named every file it downloaded to [name-of-the-album].png. Since I have a pretty large collection (around 1300 albums) I am not going to rename every single file to "cover.jpg"!

Here's the question:
Is there a way to use the "mv"-command to rename every *.png file in a directory to cover.jpg. Though, every album has its own subdirectory:

/mnt/media is the root for my media
/mnt/media/[Artis]t/[Album]

I can't re-run the amaroK-script since I haven't got the graphical environment running so I am unable to run amaroK.

I think a lovely *nix can do the job, can't it?

SUMMARY
I want to rename quite a lot of [album-name].png files to "cover.jpg". How can this be done even if the [album-name].png files are in different directories? Using the mv-command for example.

markkuk
3rd April 2006, 09:01 PM
PNG and JPG are two completely different graphics file formats. Just renaming a file isn't enough, you must actually convert the file into JPG format by ImageMagick, GIMP or some other suitable program.

jort
4th April 2006, 09:21 AM
PNG and JPG are two completely different graphics file formats. Just renaming a file isn't enough, you must actually convert the file into JPG format by ImageMagick, GIMP or some other suitable program.
I've tested it, to rename just a single png-file to jpg and it worked. Perhaps this has something to do with the fact that Linux isn't looking at the file extension but at the real file. So, I could even rename it to ".I-would-like-to-rename-all-my-cover-files.jpg" and it still would work.

Though, my cover files should be named as "cover.jpg".

Any suggestions?

markkuk
4th April 2006, 04:41 PM
OK, try the find command:

find /mnt/media -name '*.png' -execdir mv '{}' cover.jpg ';'

jort
4th April 2006, 05:17 PM
OK, try the find command:

find /mnt/media -name '*.png' -execdir mv '{}' cover.jpg ';'
That did the trick! Thank you very much!

May I ask you what it actually stands for?
find is the command, /mnt/media is the directory in which the files has to be changed, what does "-name" does? *.png -> any file which ends with .png. -execdir? Execute a specific command (mv) on directory '{}'?
";" -> just means "end of command"?