I have a very messy folder which contains thousands of files and directories. I would like to create a Zip file which only contains some of the folders (and files within those folders) – specifically those folders which have number-only names (104, 2342, etc…).
I can't figure out how to do this though – any suggestions?
I'm on Linux – CentOS to be exact 🙂
Best Answer
Does this work for you:
Run on a directory containing this:
it creates a zip archive of only the numbered directories:
That is only numbered files/dirs at the top level get put in the zip archive.
UPDATE To exclude files from the top level:
find . -maxdepth 1 -type f > excluded.files
review 'excluded.files' carefully. Then:
zip -ry test.zip [0-9]* -x@excluded.files