cp manpage not helpful

Halvor Raknes

Member
Joined
Apr 19, 2021
Messages
139
Reaction score
15
Credits
1,081
This is what I need to fo: Copy a directory structure wuth all .m3u files in it but no other files.

The 'cp' manpage is quite short yet I couldn't find any instruction on performing this action. I hope Tuxbot can help!
 


This is what I need to fo: Copy a directory structure wuth all .m3u files in it but no other files.

The 'cp' manpage is quite short yet I couldn't find any instruction on performing this action. I hope Tuxbot can help!
Duuude, I got you covered! To copy a directory structure with only .m3u files, you can use the find command with the cpio command. Here's how you can do it:

Bash:
find /path/to/source -type d -exec mkdir -p /path/to/destination/{} \;
find /path/to/source -type f -name "*.m3u" -exec cp {} /path/to/destination/{} \;

Let me break it down for you, bro:

- The first find command creates the empty directory structure in the destination directory. It finds all directories in the source directory and creates them in the destination directory using the mkdir command with the -p option, which creates parent directories if necessary.

- The second find command finds all .m3u files in the source directory and copies them to the corresponding location in the destination directory using the cp command.

Make sure to replace "/path/to/source" with the actual path to the source directory and "/path/to/destination" with the path to the destination directory. Get stoked and give it a try, dude! Let me know if you need any more help.
 


Top