7zip: Exclude hidden directories [closed] - 7zip

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
How do I exclude hidden directories when creating an archive using 7zip's command line version?
I tried -x!".*", but that didn't work.

You need to add the r ("recurse") flag to the -x option if you want it to match files inside subdirectories.
For example, the following creates an archive from the whole directory tree under folder/ except for any files that start with a dot:
7z a -xr'!.*' archive.7z folder/

I had the same problem on windows 7 64bit 7zip.
After doing some research I found the following points:
1) single/double quotes ' " does not work on windows - 7zip says incorrect wirdcard
2) excluding based on file/folder attributes is not possible - only option is either to exclude with wild cards or make an exclude list.
3) in -x option, file is denoted as < path>\< filename.ext> and a folder as < path>\< folder>/ (with a slash at the end)
4) format 1: with ! mark (pattern directly with command) you can give something like:
a) 7z a -xr!<path>\<folder to exclude>/ archive.7z <zip folder>/
This excludes .svn folder in any path from zip folder recursively
b) 7z a -xr!*\.svn/ archive.7z <folder>/
5) format 2: with # symbol you can give exclude list like this:
a) 7z a -xr#<7z exclude list file> <archive name>.7z <folder>/
where an exclude list file can have:
*\.svn/
*\output/
*\Document/
*\Measurements/
*.xlsx
*.bak
my favorite option is to use an exclude list

this would work for ignoring hidden files ...
7z.exe a -xr!.git\ -xr!*~ ".zip"

I had a problem on Win64 and an exclude file. I couldn't get the .git folder excluded. The simple ".git\" didn't work, neither any other usual patterns. In the end excluding "*git\" worked (note: no dot).

Related

How to replace string in matching directory names? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 months ago.
Improve this question
While refactoring my code I had to change some variable names from components to materials. But now I need a way to replace components to materials in all folder names that match.
Something that could take me from here
/available-components
/furniture-components
/raw-components
To here
/available-materials
/furniture-materials
/raw-materials
I would also like to know how I can exclude directories from being traversed, something like
-exclude ./node_modules
I was thinking a Bash script can do the job, but I have never touched a scripting language other than to run my C++ code or start a NodeJS server, so explanation would be greatly appreciated!
This is how the command looks alike:
find . ! -path "*node-modules*" -path "*-components" -exec rename 's/components/materials/' {} +
Explanation:
find . finds directories and files in the current directory
`! -path "node-modules" excludes anything containing node-modules
-path "*-components" means that the end of the path is components, the idea is to not attempt renaming the same nonempty folder many times
-exec specifies that we want to execute something on the result
rename 's/components/materials/ specifies what to replace and what to replace with in our collection

Deleteing specific file type from 2 directory levels up [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 10 months ago.
Improve this question
I am trying to figure out a way to make a script to remove files of a specifc type from multiple folders without removing it from the 1st directory. See below for an example.
Target file extention is .xlsm
The files to be deleted are located 2 directory levels up. But I need to skip the filetype located 1 directory level up
e.g.
\User Folder\Folder1\test.xlsm this needs to be kept
\User Folder\Folder1\SubFolder1\File.xlsm This must be deleted
\User Folder\Folder2\foo.xslm this needs to be kept
\User Folder\Folder2\Subfolder2\bar.xlsm This must be deleted
The Get-ChildItem cmdlet can take wildcards in its search path.
Try
Get-ChildItem -Path 'X:\User Folder\*\*\*' -File -Filter '*.xlsm' | Remove-Item -WhatIf
Remove the -WhatIf safety switch if what is shown in the console is correct and run again
Maybe try to do a get-childItem of Folder1 in a variable.
Then keep only folder in this variable.
And finally do your cd/set-location for delete xlsm file.
Example (I haven't try but the form is normally good) :
$VarFolder = Get-ChildItem ...\Folder1\
foreach ($item in $VarFolder){if ($(get-item $item).Attributes -eq "Directory"){$VarKeeping += $item }}
Then next of treatement with cd and remove..

Create VCF from .bim, .bed and .fam files [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I have a .fam, .bed and .bim file with markers for few individuals. I would need to convert it into a VCF file.
Could someone help to create a VCF file. Are there any opensource tools which can do this?
You can perform this operation with plink2 (https://www.cog-genomics.org/plink2/) with the following command:
plink --bfile {prefix} --recode vcf bgz --out [prefix]
See here for more options: https://www.cog-genomics.org/plink2/data#recode
However, this will not generate a properly formatted VCF, as plink2 does not keep information about what the reference allele is, while VCF format expects the first allele to be the reference allele. Indels are also often coded differently, though there is no guideline for how to code them in plink format.
For more advanced ways to perform the conversion, a combination of "bedtools getfasta" and "bcftools norm" can help you overcome the above shortcomings.
You could try PlinkSeq, or see this post:
http://bhoom.wordpress.com/2012/04/06/convert-plink-format-to-vcf/
Briefly, the post lists user code for turning plink files into vcf format:
#!/bin/sh
##-- SCRIPT PARAMETER TO MODIFY--##
PLINKFILE=csOmni25
REF_ALLELE_FILE=csOmni25.refAllele
NEWPLINKFILE=csOmni25Ref
PLINKSEQ_PROJECT=csGWAS
## ------END SCRIPT PARAMETER------ ##
#1. convert plink/binary to have the specify reference allele
plink --noweb --bfile $PLINKFILE --reference-allele $REF_ALLELE_FILE --make-bed --out $NEWPLINKFILE
#2. create plink/seq project
pseq $PLINKSEQ_PROJECT new-project
#3. load plink file into plink/seq
pseq $PLINKSEQ_PROJECT load-plink --file $NEWPLINKFILE --id $NEWPLINKFILE
#4. write out vcf file, as of today 4/6/2012 using vcftools version 0.1.8, although the documentation says that you can write out a compressed vcf format using --format BGZF option, vcftools doesn't recognize what this option is. So, I invented my own solution
pseq $PLINKSEQ_PROJECT write-vcf | gzip > $NEWPLINKFILE.vcf.gz

What is */ in Unix? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Suppose you were in your home directory in Unix and wanted to see all the sub-directories.
ls -d
Would print '.'
ls -d */
Would print every sub directory.
From the man page of ls:
-d, --directory
list directory entries instead of contents, and do not derefer‐
ence symbolic links
So, I think you are confused between directory entries and directory contents. When you do
ls -d
The 'directory entry' of current directory is printed,, which is, in my case:
.
But when you do
ls -d */
You shell will expand * to all contents of the present directory and the above command will take each directory content as argument. Hence, the output will be the 'directory entry' of each 'directory content' of the current directory, which in my case would be (where $pwd=/tmp):
ls -d */
systemd-colord.service-XwkSsOM/ systemd-rtkit-daemon.service-XH1Bbsw/
systemd-cups.service-XRwwRXh/
Note the difference when I don't use /
ls -d *
a.php ip.sh systemd-colord.service-XwkSsOM tmp.php
eiskaltdcpp-gtk.Wani.1462694194 model-one-final-rev.pdf systemd-cups.service-XRwwRXh tmp.py
hogsuspend res-failed.txt systemd-mariadb.service-XTsa5E9 yum_save_tx.2014-02-02.08-36.RhLlKa.yumtx
ip sess_ph2d61cksimbibrqrn1jru8l85 systemd-rtkit-daemon.service-XH1Bbsw
Putting '/' after * will filter out all the directory contents of the present directory which are directories themselves.
*/ matches only the subdirectories of your current directory (not the files, if any). The -d flag instructs ls to print directory names rather than listing their content.
ls -d with no parameters will list the current directory itself (again, not its contents), which is referenced by ..

How could I automate this process? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I'm new to programming/scripting. I have about 40 folders (Win7) with files containing various dates. Currently, I open each folder, search for the date I need, and then copy it elsewhere. How difficult would it be to automate this process? Could I enter the dates that I need, and the tool would then copy all the files I need to a given destination?
Would be pretty simple to whip something up with python, assuming all the dates are similar in format.
import os
import sys
import shutil
fileList = []
rootdir = sys.argv[1]
#iterate over the files
for root, subFolders, files in os.walk(rootdir):
for file in files:
#if date is in the file path add it to a list
if sys.argv[2] in root:
fileList.append(os.path.join(root,file))
#move file from one location to the new dest
for f in fileList:
shutil.move(f,sys.argv[3] + f[f.rindex("/"):])
print "moving %s to %s" % (f,sys.argv[3] + f[f.rindex("/"):])
This doesn't do any error checking, or checking if your output directory is created. but the gist is there.
python script.py directory_to_search str_to_find dest_dir
EDIT: Missed the bit that was the modified date. i'm sure there are libraries to get that kind of information. This solely looks for a string in a directory :(
EDIT EDIT: os.path.getmtime(filepath) is how you get the modified time of a file in python if i'm not mistaken.

Resources