I'd like to zip a folder, but zip skips files.
Folder structure is:
main_folder > sub_folder > file2.sql
file11.txt
file12.sql
Main_folder contains sub_folder and two files, subfolder contains one file.
When i use
zip -r $path *
i receive .zip file which contains everything except file11.txt. I tried various options but have not solved the problem. Zip makes correct structure and takes every single file except files from main_folder.
could you try this;
zip -r your.zip * -x file11.txt
man zip;
-x files
--exclude files
Explicitly exclude the specified files..
Related
I have a .txt list of filenames that I would like to copy into a new folder. The filenames take the form: 0-01-199898988999.mp4. I can use the list of file names to copy files into a new folder using the following code.
cp `cat list.txt` new_folder/
However, this only works when the files I want to copy, the .txt file, and the new folder are all in the same directory, and all of my files to copy are organized into subfolders within the directory.
FolderA
->list.txt
->new_folder
->SubA
-->0-01-199898988999.mp4
-->0-02-199898988999.mp4
-->0-03-199898988999.mp4
->SubB
-->0-04-199898988999.mp4
-->0-05-199898988999.mp4
-->0-06-199898988999.mp4
-->0-06-199898988999.mp4
How can I modify the code to search through the subdirectories of folder A?
I've tried using --parents, but it hasn't worked.
cp -v --parents `cat list.txt` /new_folder
I've been searching around for answers, but most versions of this problem involve a list with the unique directory names for each file (which I don't have), copying all the files within the subdirectories, or searching by extension instead of file name.
I have a zipped file:
main.zip
And I want to unzip only some folders present in the zipped folder while excluding the .git pack file.
The folder structure in main.zip is as follows:
main.zip -> main_folder -> folder1, folder2... and I want to extract only folder2 from the zipped file, but this folder2 contains the .git folder with packed files, which I don't need.
So far I have tried :
unzip main.zip "main_folder/folder2/*" -d ~ path/to/some/directory
!(*.git) will exclude the files ending with .git, but how do I integrate this in the command above?
The exclude option works!
We just need to provide a path to the files to be excluded!
unzip main.zip "main_folder/folder2/*" -x "main_folder/folder2/*.git/*" -d path/to/some/directory
I have a tar.gz file which includes 2 tar files and each tar file includes several folders and subfolders that include my required files.
I want to extract the final files from those subfolders in a directory.
I know I can use something like tar -xzvf but finally, it gives me all the folders and subfolders and the files I needed in those subfolders.
Example file:
file.tar.gz: this file contains 1.tar and 2.tar. 1.tar contains folder1, folder2, ..., folder100. and 2.tar contains foldera, folderb, ..., folderz. My text files are in these subfolders.
I want to extract all of my text files in a user-defined directory without extracting subfolders. my_dir/*.txt
Any help would be much appreciated.
Thank you.
I have files in a directory, with a pattern in the filename ("IMP-"). I need to copy the files from the directory A to the directory B. But I also keep the files in the directory A. So in order to copy only the new files in directory B, I need, first to list each time I do a copy, the filenames in a text file (list.txt), and then to copy only the files that aren't listed in the text file.
exemple
Directory A (/home/ftp/recep/)
files, for example can be :
/home/recep/IMP-avis2018.txt
/home/recep/IMP-avis2018.pdf
/home/recep/IMP-avis2017.jpg
/home/recep/IMP-avis2017.pdf
Directory B (/home/ftp/transfert/)
In need to copy all files with IMP* to directory B (/home/ftp/transfert/).
And when a new file is receive in drectory A, I need this file, and only this file, to be copied in directory B (where files only stay 2 hours max)
I tought maybe I could do something with rsync, but I could'n find an adequate option.
So maybe it could be a bash script.
Actions would be :
have a simple basic text file containing already proceed files (for example liste.txt)
find files in directory A containing pattern IMP
for each of these files, read the liste.txt file and if the file is not listed in liste.txt, copy it to the directory B
You could try the option -n. The man page says:
-n, --no-clobber
do not overwrite an existing file (overrides a previous -i option)
So
cp -n A/* B/
should copy all files from A to B, except those that are already in B.
Another way would be rsync:
rsync -vu A/* B/
This syncs the files from A to B and prints the file that were actually copied.
I have a folder named images with 7000 subfolders in it named 1, 2, 3... until 7000.
I need to zip only the folders where folder name > 6000.
Is this possible?
I was trying to exclude folders like:
zip -r myarchive.zip dir1 -x dir1/ignoreDir1/**\* dir1/ignoreDir2/**\*
but this is too long to perform with 7000 folders.
Instead of excluding, select only the ones you need. You can use the single character wildcard ? to select subfolder names with specific length:
zip -r archive.zip images/6???/* images/7???/*
This will add all files to the archive from images/6000/* to images/7999/*