Contents
How to zip all subdirectories in a directory?
There are several threads on zipping subdirs, but not on the conditions I have. To be more precise: I do not want to zip all *.txt files, but all directories that exclusively contain txt-files into a directory .zip and delete the original directory.
How to zip a file without the Dir?
My goal is to zip the file from outside this folder (so without using cd command) without including the folder dir. This command includes the folder dir in the final zip. Any hints? If you want to store all the files in folder under their name without a directory indication, you can use the -j option.
How to zip all folders in a directory?
To be more precise: I do not want to zip all *.txt files, but all directories that exclusively contain txt-files into a directory .zip and delete the original directory. This script will archive then optionally remove all folders containing “*.txt” files and nothing else.
What happens if you include a file in a subdirectory?
If you do that, if you include files in subdirectories, they’ll have their relative path from the directory you changed into, e.g. folder/subdir/foo will be stored as subdir/foo. For interactive use, you lose shell completion this way, because the shell doesn’t realize that you’ll be in a different directory when you run the zip command.
How to zip specific files that are located?
Each subdirectory contains files such as: As you can see, each file has different duplicates in different subdirectories. For example, Run1.csv in folder A has different data from Run1.csv in folder C. What I want to do is that I want to zip a specific run file, for example, I want to zip all the files of run2.
How to unzip files from the command line?
It was Archive Utility’s fault (a Mac OS X unzipper app). When I used the unzip command from the command line, it works great. (cd MyFolder && zip -r -X “../MyFolder.zip” .) Stumbled across this answer but didnt want to have to change in out of directories. I found the -j option useful which adds all files to the root of the zip.
How to find all Zips and unzip in place?
This command looks in current directory and in its subdirectories recursively for files with names matching *.zip pattern. For file found it executes command sh with two parameters: Where is name of file that was found. Command sh is Unix shell interpreter. Option -c tells shell that next argument should be interpreted as shell script.
How to search all subdirectories in Bash?
For a more general solution of finding one or more directories and searching them for something like finding old email addresses in git repositories look at the following pattern: This works out of the box in zsh. In bash, you need to run shopt -s globstar first, and beware that this also traverses symbolic links to directories.
Do you include the root folder in a zip file?
I want to zip the content (files and sub folders) of folder without including the root folder in the zip. But this includes the root folder. Also tried the following form But this will flatten all the directory structures and just include the files.