I want to zip two folders which are distinct in names in a base directory. Finally that zip file has to be present in the base directory. In this case, my destination directory is the base directory.
How could I do this in an ANT script?
Something like this should do it:
<zip destfile="${base.directory}/zipfile.zip"
basedir="${base.directory}"
includes="dir1/**,dir2/**"
/>
Related
for file in os.listdir(r'C:\Users\user\Downloads\plant_tomato_leaf_dataset\plantvillage'):
for cl in os.listdir(r'C:\Users\user\Downloads\plant_tomato_leaf_dataset\plantvillage\\'+file):
print(file)
print(cl)
print('******************')
I have a folder "plantvillage". Inside that folder I have 10 folder. I have to access all the sub-folders and perform operations on those sub-folder-items. But this code is showing only items of the first folder
You might be interested in os.walk instead of os.listdir. listdir is not recursive.
An example would be:
for root, dirs, files in os.walk(r'C:\Users\user\Downloads\plant_tomato_leaf_dataset\plantvillage'):
for file in files:
print(os.path.join(root,file))
this will run the inner loop as many times as there are directories, and will also check to make sure that each file is actually a file. If you want to look at the directories themselves for some reason (ignoring files), you can do that like so:
for root, dirs, files in os.walk(r'C:\Users\user\Downloads\plant_tomato_leaf_dataset\plantvillage'):
for directory in dirs:
print(os.path.join(root,directory))
but don't try to mix and match. Getting the current directory is easy when iterating files. It's just root.
I want to create a zip archive for some files in folder hierarchy.
for example:
abc.php_0973_890
newone.text_2344_870
I want to have:
abc.phpnewone.txt in my zip archive. Is there any way for doing this?
We can not do that as zip doesnot suuport anything like that, we can use tar for such things as it as options like: --transform which can be used to transform the output filename
I would like to remove all svn directories from a zip file. Can not find correct pattern. This is the pattern I tried ".svn/*"
Was able to remove all .class files.
Found pattern. Should work for any directory.
"/.svn/"
Avoid the problem in the first place. Don't create your zip file directly from your working copy. Just use svn export to create a new directory without the .svn directories, and without any unversioned files, and zip that instead.
If I have a list of files I want to zip, how can I pass the list to zip?
cookbook/application/views/index.php
cookbook/application/controller/index.php
cookbook/js/index.js
....
cookbook/css/index.css
To do the above list one by one at the command-line would be like zip -r my.zip cookbook/css/index.css, where my.zip is in the same root directory as cookbook
Try
zip -r# my.zip < listfile
The -# flag tells zip to read file names from stdin.
If all files are in the same folder, you don't need to type each file that you want to include in the archive. Just invoke the command and specify their common folder like this:
zip -r cookbook.zip cookbook
All files inside the cookbook directory will be included in the zip archive.
Is there a way not to symlink one or two files within a symlinked directory in CentOS?
I've got the entire directory symlinked but there are two css files that I would like to use the current copy for the website
In short: no.
Another way to do this would be to symlink all the files in that directory, except those you want local copy of.
Still another way to go might be using unionfs or aufs to union-mount the original directory and a directory containing the files you need local, with the directory containing local files being "on top".
Say, your original directory is orig, the directory with files that should be local is local, the union directory is union, and you want files from both directories to be writable. Then you can union-mount them like this:
unionfs-fuse local=RW:orig=RW union
And unmount like this:
fusermount -u union
See unionfs manpage (unionfs-fuse(8) at least on Debian) for details.