MorganR
MorganR

Reputation: 659

Move only mp3s within multiple directories to a single folder

This solution from SO works but unfortunately some of my mp3s have quotes (') in their names which results in the following error:

xargs: unterminated quote

Is it possible to adapt the following command to allow it to copy all mp3s, regardless of the quotes in their file name?

find . -name "*.mp3" | xargs -I {} cp -iv "{}" /my/dir

Thank you.

Upvotes: 0

Views: 362

Answers (2)

Nahuel Fouilleul
Nahuel Fouilleul

Reputation: 19315

find . -name "*.mp3" -exec cp -iv {} /my/dir \;

Upvotes: 3

Michael Krelin - hacker
Michael Krelin - hacker

Reputation: 143081

Try adding -print0 to find and -0 to xargs.

Upvotes: 4

Related Questions