cp -Rp excluding certain files?

Hi,

I'm using cp -Rp to copy directories while preserving permissions. I want to exclude any ".lproj" files except for "English.lproj" and "en.lproj" from being copied, but the rest is copied as usual. Is there a way to do this (without using tar or other compression utilities)

Thanks

It always helps to know what Operating System and shell you are using.
In this case a sample source and destination directory tree would help.
If we assume that the trees do not overlap, the task becomes much easier:
e.g.
/parent/source_tree
/parent/destination_tree
then I'd be inclined to use a combination of "find" and "cpio -pdum" rather than just "cp". See the "man" pages for both "find" and "cpio" for examples. There is much variation across unix and Linux of the exact syntax.

It looks easier to run two separate copies:
1) All files except any ".lproj" .
2) "English.lproj" and "en.lproj" .

As with all bulk file operations rehearse your script on a test tree before mentioning live files. Test thoroughly.

I'm using Mac OS X 10.6.1 with the standard bash shell.

source_tree:

  • Contents
    -- Resources
    ---- English.lproj
    ---- French.lproj
    ---- German.lproj

destination_tree is an exact copy of the source_tree excluding the .lproj files (except for English.lproj or en.lproj)

Try this:

cd /source/dir
find * -not \( -name English.lproj -or -name en.lproj \) | cpio -pvdmu /dest/dir