Zip all files in the directory by windows command - windows

Zip all the files in the specific directory and I need to place the zip file in the same folder through windows command prompt.
I know command for unzip as below
"unzip SRCPath -d DestPath "
I am looking all the text files to compress and place the zip file in the same folder.

Related

How to delete the files from a directory, when the names of the files are saved in the CSV file, using CMD?

I used the following command to delete files (the name of the files are saved in a CSV file) from my directory:
del >dir list.csv
But it deleted the file list.csv and created a dir file.
What command should I use?

How to run a .sh script to create a *.zip file?

I try to write a shell script create_zip.sh to zip my desired folders as a .zip file.
The content of create_zip.sh is as following:
CODE_DIR='exercise_code/'
EXERCISE_ZIP_NAME='exercise_01.zip'
EXERCISE_DIR=$(pwd)
echo 'Zipping file '$EXERCISE_ZIP_NAME
zip -r $EXERCISE_ZIP_NAME $CODE_DIR
echo $EXERCISE_ZIP_NAME ' created successfully!!! '
But when I double-clicked on the file create_zip.sh, it just opened the Git Bash window and closed immediately. Then nothing happened! (No output message, no newly created *.zip)
How can I solve it? I am using Win10 and with Git Bash as default application to open *.sh file.
Any solution will be very appreciated.
You probably don't have zip installed in Git Bash.
Try the following steps:
Navigate to https://sourceforge.net/projects/gnuwin32/files/zip/3.0/
Download zip-3.0-bin.zip
In the zipped file, in the bin folder, find
the file zip.exe
Extract the file "zip.exe" to your "mingw64" bin
folder (for me: C:\Program Files\Git\mingw64\bin)
Navigate to https://sourceforge.net/projects/gnuwin32/files/bzip2/1.0.5/
Download bzip2-1.0.5-bin.zip
In the zipped file, in the bin folder, find the file bzip2.dll
Extract bzip2.dll to your "mingw64" bin folder (same folder - C:\Program Files\Git\mingw64\bin)

Name not matched in creating zip folder with bash

I'm trying to create a zip folder in a bash script that contains the current date (YYYY_MM_DD).
I have this code:
currentArchive=$(date '+%Y_%m_%d')
zip -r ./aktuell ./Archive/${currentArchive}-bkt
But when I run the script I get the following error:
zip warning: name not matched: ./Archive/2017_03_30-bkt
I want the folder "aktuell" as a zip folder named "2017_03_30-bkt.zip" in the folder "Archive". The current folder "aktuell" exists.
What am I doing wrong?
You have the source and destination directories backwards in your zip command. Also, make sure the destination directory exists before executing zip.
currentArchive=$(date '+%Y_%m_%d')
mkdir -p ./Archive/
zip -r ./Archive/${currentArchive}-bkt ./aktuell

7z how to avoid extracting subfolders' files

I am trying to append a script in my JAVA program to unzip the files in specific folder by 7z. Here come below script. But I found that it will also extract the .zip files in subfolder.
7z e -aoa -ppassword c:\xxx\desktop\fromFolder -oc:\xxx\desktop\toFolder > nul:
What if I want to extract the .zip files located in "fromFolder" only and exclude all files in the subfolders of "fromFolder". Please advice, thanks.

How do I Unzip a file, replace a file with a new copy and re-zip the file in Apple script?

I have a string with the path to a .ipa file:
set ipa_path to POSIX path of ipa_file
Now I want to:
Un-zip the .ipa file (its really a zip file)
Replace a file in the zip called "embedded.mobileprovision" with a new version of the file.
Re-zip the file and replace the original ipa file.
So for I have:
do shell script "unzip " & ipa_path
Is this right so far? I just started to learn AppleScript today ...
You don't really need AppleScript for this. The command line zip utility has the -r option to replace existing files (of the same name and relative path) within a zip archive. Here's a quote from the man page man zip:
if foo.zip exists and contains foo/file1 and foo/file2, and the
directory foo contains the files foo/file1 and foo/file3, then:
zip -r foo.zip foo
will replace foo/file1 in foo.zip and add foo/file3 to foo.zip.
Of course, you can still wrap the calls to zip in AppleScript do shell script commands.

Resources