[plug] Recursive Copying of Folder Contents
Bernd Felsche
berfel at innovative.iinet.net.au
Thu Jun 4 13:50:11 WST 2009
Gregory Orange <gregory.orange at rpsmetocean.com> wrote:
>Andrew Furey wrote:
>> On 04/06/2009, Jason Posavec <jasonposavec at iinet.net.au> wrote:
>>>> $ cp Music/*/*/* common-folder /
>>> That would only copy files, and not folders? If so, it proves that the best
>>> solutions are always the simplest and most elegant. At first glance, that
>>> command looks like it would copy *everything* in the 3 folders under Music,
>>> not just the files.
>>
>> Actually it'll copy everything in the-3-folders-under-Music, not the
>> ones in the levels above. You're thinking of:
>>
>> $ cp Music/* Music/*/* Music/*/*/* common-folder
>The find a la BillK will work elegantly, rather than munging together
>args to cp that might miss some. It might not be super high performance,
>and I've heard xargs can help there. I wouldn't bother though, clock
>cycles are cheap (:
find Music/*/*/* -print0 | cpio -pdm0 common-folder
Would copy the tree.
The print0 and ZERO options specify null-termination of filenames.
Else embedded field and record separators confuddle the copier.
--
/"\ Bernd Felsche - Innovative Reckoning, Perth, Western Australia
\ / ASCII ribbon campaign | When we remember that we are all mad,
X against HTML mail | the mysteries disappear and life stands
/ \ and postings | explained. -- Mark Twain
More information about the plug
mailing list