Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I installed a new music application. It reads covers.jpg as the cover of the album, however, my covers files where named album. I dont want to rename, I want to make a copy of album.jpg and if possible as well rename it to covers.jpg. The file has to be in the same folder that it currently is. I have looked around to see how I can do this but have not been able to.
thanks for the reply. I am looking for a more automated way of doing it. Using the find exec cp commands would prob do it, I just dont know the complete command for it.
I'm assuming you mean you have all those directories together (in the same root/parent dir), as in:
Code:
music/album1
music/album2
...
music/albumN
And want to change the paths like this:
Code:
album1/album.jpg --> album1/covers.jpg
If this is the case, you can just use a "for" (in bash) sentence to copy every dir's album.jpg file to the same dir's covers.jpg file, like this:
Code:
#cd music
for dir in * ; do cp $dir/album.jpg $dir/covers.jpg ; done
It doesn't check for files in the dirs, and takes all the files in the current dir, so it will return errors if you have a path like "music/file.txt", but it won't delete anything^^.
This is a what is like. It is giving me this errors:
cp: target `Project/cover.jpg' is not a directory
cp: target `(CD2)/cover.jpg' is not a directory
cp: target `CD2/cover.jpg' is not a directory
cp: target `Vavavoom/cover.jpg' is not a directory
cp: target `Contraband/cover.jpg' is not a directory
I installed a new music application. It reads covers.jpg as the cover of the album, however, my covers files where named album. I dont want to rename, I want to make a copy of album.jpg and if possible as well rename it to covers.jpg. The file has to be in the same folder that it currently is. I have looked around to see how I can do this but have not been able to.
It would be great if you could return the output of a quick "ls" too^^.
I can only guess, you have spaces in your directory names. Also having your locale in another language (do "locale" to check?) may have something to do.
Anyway, if it's only that you have spaces in the dir names, make a script (save this to text to "script.sh" or something) with the following:
Code:
IFS='
'
for dir in * ; do cp $dir/album.jpg $dir/covers.jpg ; done
This sets the internal field separator (IFS) only to newlines (return key), not including spaces as default. I think the parenthesis shouldn't be a problem...
It would be great if you could return the output of a quick "ls" too^^.
I can only guess, you have spaces in your directory names. Also having your locale in another language (do "locale" to check?) may have something to do.
Anyway, if it's only that you have spaces in the dir names, make a script (save this to text to "script.sh" or something) with the following:
Code:
IFS='
'
for dir in * ; do cp $dir/album.jpg $dir/covers.jpg ; done
This sets the internal field separator (IFS) only to newlines (return key), not including spaces as default. I think the parenthesis shouldn't be a problem...
Wow, crts's code is better... find is amazing.
Bingo!! that was it, spaces between . Thanks alot! very helpful. No way I could have come up with this.
ahaha^^ that's too bad. You should really be a little more specific. Like instead of saying it didn't get all of them, telling which ones it didn't get, or even better, do an "find" in that dir and paste the output here, etc. It's kind of hard keeping guessing^^.
I can only guess, you maybe have some subdirectories in the same directory structure, so the code I gave you wouldn't work right (being that is only reading the files/dirs in the current directory). In that case the script would become kinda long/complicated/plain ugly.
crts's code is most likely to work in such a case too, did you try it?
find: The current directory is included in the PATH environment variable, which is insecure in combination with the -execdir action of find. Please remove the current directory from your $PATH (that is, remove "." or leading or trailing colons)
I do have subdirectories..I tried posting my music library tree but it is too long. let me try a smaller list
|-- Dishwalla - Pet Your Friends
| |-- Dishwalla - Pet Your Friends - 01 - Pretty Babies.ogg
| |-- Dishwalla - Pet Your Friends - 02 - Haze.ogg
| |-- Dishwalla - Pet Your Friends - 03 - Counting Blue Cars.ogg
| |-- Dishwalla - Pet Your Friends - 04 - Explode.ogg
| |-- Dishwalla - Pet Your Friends - 05 - Charlie Brown's Parents.ogg
| |-- Dishwalla - Pet Your Friends - 06 - Give.ogg
| |-- Dishwalla - Pet Your Friends - 07 - Miss Emma Peel.ogg
| |-- Dishwalla - Pet Your Friends - 08 - Moisture.ogg
| |-- Dishwalla - Pet Your Friends - 09 - The Feeder.ogg
| |-- Dishwalla - Pet Your Friends - 10 - All She Can See.ogg
| |-- Dishwalla - Pet Your Friends - 11 - Only For so Long.ogg
| |-- Dishwalla - Pet Your Friends - 12 - Interview With St. Etienne.ogg
| |-- Dishwalla - Pet Your Friends.ogg.m3u
| |-- album.jpg
| `-- cover.jpg
|-- Eagles of Death Metal
| |-- Eagles Of Death Metal - Peace Love Death Metal
| | |-- Eagles Of Death Metal - Already Died.mp3
| | |-- Eagles Of Death Metal - Bad Dream Mama.mp3
| | |-- Eagles Of Death Metal - English Girl.mp3
| | |-- Eagles Of Death Metal - Flames Go Higher.mp3
| | |-- Eagles Of Death Metal - I Only Want You.mp3
| | |-- Eagles Of Death Metal - Kiss the Devil.mp3
| | |-- Eagles Of Death Metal - Midnight Creeper.mp3
| | |-- Eagles Of Death Metal - Miss Alissa.mp3
| | |-- Eagles Of Death Metal - San Berdoo Sunburn.mp3
| | |-- Eagles Of Death Metal - So Easy.mp3
| | |-- Eagles Of Death Metal - Speaking In Tongues.mp3
| | |-- Eagles Of Death Metal - Stacks O Money.mp3
| | |-- Eagles Of Death Metal - Stuck In The Metal.mp3
| | |-- Eagles Of Death Metal - Wastin My Time.mp3
| | |-- Eagles Of Death Metal - Whorehoppin (Shit, Goddamn).mp3
| | |-- album.jpg
| | `-- playlist.m3u
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.