This is driving me nuts. All google results are for the reverse scenario.
So I have a directory structure like:
MyFiles
| file1
| file2
| file3
| MoreFiles
| | file4
| | file5
And what I want is an archive (preferably zip as I'm passing along process to non-tar users, but bonus points for answers showing how to in zip and tar) that looks like:
archive.zip
| MoreFiles
| | file4
| | file5
So that the top-level files are excluded but the sub-directories and their files are include.
So far, the best I could come up with is:
zip -r archive.zip MyFiles -x "."
but this excludes all files at every level, so I just end up with the directory structure. I only want to exclude the directories sitting directly in the target directory.
Oh! And actually, my real-world use-case is to exclude the contents of one specific sub-directory, so working from the next-deepest level isn't a workaround. The real scenario is:
MyFiles
| file1
| file2
| file3
| Level1Files1
| | file4
| | file5
| | Level2Files1
| | | file6
| | | file7
| | Level2Files2
| | | file8
| | | file9
| Level1Files2
| Level1Files3
with the end goal of including everything at the top level, but exclude files inside specific subdirectory, but not exclude the subdirectories inside that first subdirectory or their contents, so that if I wanted to exclude top files of subdirectory Level1Files1 in above , the result would be:
archive.zip
| file1
| file2
| file3
| Level1Files1
| | Level2Files1
| | | file6
| | | file7
| | Level2Files2
| | | file8
| | | file9
| Level1Files2
| Level1Files3