gnu makefile: generating .zip with a subfolder - makefile

I have a makefile which gets the content from a folder and saves it on a .zip file. Pretty darn good! The problem is, I want this content to be in a subfolder instead of the root folder of the zip file.
Today: file.zip/content
I want: file.zip/fubfolder/content
This is a piece of my code:
buildall: $(BUILDDIR)/index.html \
$(BUILDDIR)/assets/json
NET_CLIMATEMPO_APP_$(REL).zip: buildall
cd $(BUILDDIR); zip -r ../NET_CLIMATEMPO_APP_$(REL).zip .
Can anybody help me here?
Thank you a lot!

Related

Bash, move and rename files to base parent directory name

I have a bunch of base-parent-folders with different names.
In each of these base-parent-folders i have a folder with same same name(result).
In each of the result folders, i have a result file (data.txt), also named the same in each base-parent-folder.
I need to move all the data.txt files to a new folder (newfolder), and rename them to the base-parent-folder name.
for name in ./*/*/data.txt; do
mv "$name" "../newfolder/$(basename -- "$(dirname -- "$name")").txt";
done
This will move the file but rename the data.txt files to result.txt, and not the unique base-parent-folder name.
Help is much appreciated :D
What i have:
data\data1\result\data.txt
data\data2\result\data.txt
data\data3\result\data.txt
data\data4\result\data.txt
data\data5\result\data.txt
What i want:
data\newfolder\data1.txt
data\newfolder\data2.txt
data\newfolder\data3.txt
data\newfolder\data4.txt
data\newfolder\data5.txt
for f in */*/data.txt;
do mv "$f" "./newfolder/${f%/*/*}.txt";
done
Worked for me. The ./ part did not work. It wanted to add a additional folder called . when moving the file.
Thanks for the help

bash zip omit files

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..

moving files with specific extension to directory

I am trying to move all files with a .multianno.txt from one directory to another. I thought the command below would work but maybe the * is causing problems. Thank you :).
mv /home/cmccabe/Desktop/NGS/annovar/*.multianno.txt /home/cmccabe/Desktop/NGS/API/2-12-2015/annovar/
mv: cannot stat ‘/home/cmccabe/Desktop/NGS/annovar/*.multianno.txt’: No such file or directory
directory (/home/cmccabe/Desktop/NGS/annovar)
TSVC_variants_IonXpress_001_variant_strandbias_readcount.vcf.hg19_multianno.txt
TSVC_variants_IonXpress_002_variant_strandbias_readcount.vcf.hg19_multianno.txt
TSVC_variants_IonXpress_003_variant_strandbias_readcount.vcf.hg19_multianno.txt
Your filenames end in _multianno.txt, not .multianno.txt, so use
mv /home/cmccabe/Desktop/NGS/annovar/*_multianno.txt /home/cmccabe/Desktop/NGS/API/2-12-2015/annovar/

How to copy a directory with symbolic links and resolve them?

I would like to recursively copy the contents of a directory which contains symbolic links (symlinks) as well as normal files with a Bash / Shell Script. I don’t know how to copy the symlink-contents. The pseudocode would look something like this:
for file in directory do
if is symlink
resolve symlink and copy its contents
else
copy the file / folder
My directory-structure looks like this:
base/
dir1/
symlinkdir1*/ (--> ../somewhere/else/dirA)
/file1
/file2
symlinkdir2*/ (--> ../somewhere/else/dirB)
/file3
/file4
…
After the copy-procedure, I would like to have a directory-structure like this:
base/
dir1/
symlinkdir1/ (no symlink, actual directory)
/file1
/file2
symlinkdir2/ (no symlink, actual directory)
/file3
/file4
…
cp -rL /source /destination
r = recursive
L = follow and expand symlinks
Just use cp command with -r option to recursively copy. No need of a script all together,

rsync with folder and file name pattern matching to copy files

Right now I'm successfully running:
rsync -uvma --include="*/" --include="*.css" --exclude="*" $spec_dir $css_spec_dir
In a shell script which copies all of the files in the source directory, that are .css files, into a target directory.
I want to do the same for HTML files, but only where they are in a subfolder with the name 'template'.
So I'm in directory ~/foo, and I want to rsync where the --include="*/" only matches on subfolders with the name 'template'. So ~/foo/bar/template/baz/somefile.html would match, and so would ~foo/bar/baz/qux/template/someotherfile.html, but NOT ~/foo/bar/thirdfile.html
Although it looks a little bit strange, this works for me:
rsync -uvma --include="*/" --include="*/template/*/*.html" --include="*/template/*.html" --include="template/*.html" --include="template/*/*.html" --exclude="*" $spec_dir $html_spec_dir
This one works for me:
rsync -umva --include="**/templates/**/*.html" --exclude="*.html" source/ target
Were you looking for **? Here you have to be careful about choosing your exclude pattern, * won't work as it matches directories on the way. If rsync finds foo/templates/some.html, it will first copy foo, then foo/templates and then foo/templates/some.html, but before it gets there * already matched foo and nothing gets copied.
Here's what worked:
rsync -uvma --include="*/" --include="templates/**.html" --exclude="*" $html_all_dir $html_dir
My guess is, your format and mine probably accomplish the same thing. I know I tried about 20 different patterns before this one, and this is the only one that worked properly. I don't think I tried your format though :)

Resources