How to ZIP specific files from a folder using Winzip command line? - command-line

With this command, I'm able to ZIP all files from the folders:
wzzip.exe -a -p -r C:\DestinationPath\DataFiles_20130903.zip C:\SourcePath\*.*
But, my folder has .dat,.bat,.txt,.xls files.I want to ZIP only .dat and .bat file.How to do this?
Thanks.

use this command (for the particular scenario in the question):
wzzip.exe -a -p -r C:\DestinationPath\DataFiles_20130903.zip C:\SourcePath\*.dat C:\SourcePath\*.bat
for more command line options for winZip refer to the following links:
winZip command line Reference 1
winZip command line Reference 2
To provide multiple file names you can also use #filename where the filename is a file which contains the list of files which you want to include in the zip file.
If you are making the command configurable then you can ask the user/ other program which is calling your command to select the file extensions and then write these selected extensions into the "filename" file using java code or any other language you prefer.
For example if the user selects bat and dat , then write "C:\SourcePath\*.bat" and "C:\SourcePath\*.dat" into the file(assume filename is fileExtensions.txt) and call the command
wzzip.exe -a -p -r "C:\DestinationPath\DataFiles_20130903.zip" #"C:\SourcePath\fileExtensions.txt"

You can use the D7zip
An excellent zipador file and folders D7zip.exe
link to download
https://drive.google.com/file/d/0B4bu9X3c-WZqdlVlZFV4Wl9QWDA/edit?usp=sharing
How to use
compressing files
D7Zip.exe -z "c:\fileout.zip" -f "C:\filein.txt"
compressing files and putting password
D7Zip.exe -z "c:\fileout.zip" -f "C:\filein.txt" -s "123"
compressing folders
D7Zip.exe -z "c:\folderout.zip" -f "C:\folderin\"
unzipping files
D7Zip.exe -u "c:\fileout.zip" -f "c:\folderout\"
unzipping files that have password
D7Zip.exe -u "c:\fileout.zip" -f "c:\folderout\" -s "123"
decompressing files by extension
D7Zip.exe -u "c:\fileout.zip" -f "c:\folderout\*.txt"
decompressing files without asking for confirmation to replace
D7Zip.exe -u "c:\fileout.zip" -f "c:\folderout\" -r
help
D7Zip.exe -?
D7Zip.exe by Delmar Grande.

If the command line given above is right then give this a go: but check the paths.
#echo off
pushd "C:\SourcePath"
"c:\program files\winzip\wzzip.exe" -a -p -r "C:\DestinationPath\DataFiles_20130903.zip" *.dat *.bat
popd

Related

How to create a folder to save output in Postgresql?

If I'd like to save the output from file1.sql to a new file file2.sql, I would use this command in terminal/cmd:
psql -U postgres -f file1.sql -o file2.sql
What if, though, I want file2.sql to be in a different folder?
If I try this command:
psql -U postgres -f file1.sql -o New/file2.sql,
that won't automatically make a new folder and will give an error. The New folder needs to exist before I can do this.
I need to this over many output files and many new folders. One obvious alternative would be to pre-create the required folders using Python, but really, is there no way Postgresql can create folders for me?
Use mkdir -p.
It will try to create a directory New if it doesn't exist or does nothing if it already exists.The && ensures that
your psql command runs only if the mkdir command succeeds.
mkdir -p New && psql -U postgres -f file1.sql -o New/file2.sql
If you want to run os commands inside psql, simply use \! <command> option within file1.sql and then output via \o option.
\! mkdir -p New
\o New/file2.sql

How to open RECORD.alM file from mimic2db in Cygwin?

I try to open annotation file from mimic2 db for patient a40017 that called a40017.alM.
I have this link for the data: http://www.physionet.org/pn5/mimic2db/a40017/
and I don't find the exact command in Cygwin that export the file to csv or text.
I try to use this command:
rdann -r mimic2db/a40017/a40017 -f 0 -t 216647.728 -a alM -v >annotations.txt
but I got an empty file
Is anyone know how can I do that?
Thanks,
Gal
Anwering myself. Rdann is a mingw32/64 program
https://physionet.org/physiotools/binaries/windows/
If you are in the same directory of the program and it is not in the PATH you need to run:
./rdann -r mimic2db/a40017/a40017 -f 0 -t 216647.728 -a alM -v
or
/<fullpath>/rdann ...

wget corrupted file .zip file error

I am using wget to try and download two .zip files (SWVF_1_44.zip and SWVF_44_88.zip) from this site: http://www2.sos.state.oh.us/pls/voter/f?p=111:1:0::NO:RP:P1_TYPE:STATE
when I run:
wget -r -l1 -H -t1 -nd -N -np -A.zip -erobots=off "http://www2.sos.state.oh.us/pls/voter/f?p=111:1:0::NO:RP:P1_TYPE:STATE/SWVF_1_44.zip"
I get a downloaded zip file that has a screwed up name (f#p=111%3A1%3A0%3A%3ANO%3ARP%3AP1_TYPE%3ASTATE%2FSWVF_1_44) and it cannot be opened.
Any thoughts on where my code is wrong?
There's nothing "wrong" with your code. Wget is simply assuming you want to save the file in the same name that appears in the url. Use the -O option to specify an output file:
wget blahblahblah -O useablefilename.zip

How to execute multiple sql files in postgreSQL linux?

I have many .sql files in a folder (/home/myHSH/scripts) in linux debian. I want to know the command to execute or run all sql files inside the folder into postgreSQL v9.1 database.
PostgreSQL informations:
Database name=coolDB
User name=coolUser
Nice to have: if you know how to execute multiple sql files through GUI tools too like pgAdmin3.
From your command line, assuming you're using either Bash or ZSH (in short, anything but csh/tcsh):
for f in *.sql;
do
psql coolDB coolUser -f "$f"
done
The find command combined with -exec or xargs can make this really easy.
If you want to execute psql once per file, you can use the exec command like this
find . -iname "*.sql" -exec psql -U username -d databasename -q -f {} \;
-exec will execute the command once per result.
The psql command allows you to specify multiple files by calling each file with a new -f argument. e.g. you could build a command such as
psql -U username -d databasename -q -f file1 -f file2
This can be accomplished by piping the result of the find to an xargs command once to format the files with the -f argument and then again to execute the command itself.
find . -iname "*.sql" | xargs printf -- ' -f %s' | xargs -t psql -U username -d databasename -q

How do I move/copy a symlink to a different folder as a symlink under Solaris?

It is an odd behaviour seen only on Solaris that when I try to copy a symbolic link with the "cp -R -P" command to some other folder with a different name, it copies the entire directory/file it's pointing to.
For example:
link -> dir
cp -R -P link folder/new_link
I believe the "-d" argument is what you need.
As per the cp man page:
-d same as --no-dereference --preserve=link
Example:
cp -d -R -P link folder/new_link
I was using "cp -d" and that worked for me.
The cp man page seems to say that you want to use an '-H' to preserve symlinks within the source directory.
You might consider copying via tar, like tar -cf - srcdir|(cd somedir;tar -xf -)
Try using cpio (with the -p (pass) option) or the old tar in a pipe trick.