Bash my files into shape.
November 21, 2009 9:37 AM
Subscribe
My command line/scripting-fu is weak. Help me clean up and copy a lot of files without having to do it by hand?
I keep a full version of my music library on an HTPC, running Ubuntu. When I acquire new music, I always do so on my Windows laptop, and I also make sure to get a high-quality image of the album cover. For various reasons, I switched a while ago from naming the cover Folder.jpg to naming it front.jpg. Periodically, I push the new stuff onto the HTPC.
Now my album art on the Ubuntu machine is a mess. There are two things I would like to do. First, I want to delete any files called "Folder.jpg" that are located in folders that also have a "front.jpg." Second, I want to copy (not move) all of the "front.jpg" files to new "Folder.jpg" files. (This is because a lot of the older Folder.jpg files are wrong, borked, or lower quality). I suppose part two could solve part one by overwriting the older Folder.jpg, but I'm not confident that the case is always the same (i.e. always Folder.jpg and not folder.jpg).
Here's the directory structure of the files: /media/Drive/Audio/Artist Name/Album Name/<song files, album art images, etc.).
I have pretty rudimentary command line skills, and I can't find any way to make cp do what I want. My intuition, though, is that there must be some automated and reasonably simple way of doing this. Any assistance with sorting this out would be greatly appreciated.
posted by sinfony to technology (3 comments total)
4 users marked this as a favorite
find /media -name "front.jpg" -execdir cp front.jpg Folder.jpg \;posted by Mwongozi at 9:46 AM on November 21, 2009