MLUG: Re: [MLUG] cp -R --skip [pattern]?
Re: [MLUG] cp -R --skip [pattern]?
Email address obfuscation in effect -- please click here to turn it off.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Mike Miller wrote:
I don't think this exists, but this is what I'd like: A way to copy a directory tree but ignoring certain files, or copying files of a certain type only.

I have a directory tree with MP3 files in it, but there also are HTML files (album reviews) and JPEG files (album covers). I would like to replicate that directory tree without the MP3 files. I know that I could copy the whole thing and then delete the MP3 files, but they are huge and that is not feasible.

I would think there is a simply GNUish Linuxy trick to this, possibly using "find" somehow. I think I see a way to write a script that uses find, but it wouldn't be all that efficient. For example, I can write out the entire directory tree like so:

find . -type d -print

I can process that output to do what I want, but I see no way to do it with xargs -- I would use perl to create a shell script from the output, then execute the shell script. But isn't there a one-liner for this?

It would be great if one of you guys could suggest something.

Thanks in advance.

Mike

Maybe something like this? I haven't tested it, but I would think that something like this would work.


tar cvf --exclude "*mp3" - directory-to-copy \
| (cd where-you-want-copy; tar xfp -)

You can remove the first "v" if you don't want verbose output.

Stephen

_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members