How do I keep WZZIP from creating a zip that makes a folder when unzipped? - batch-file

I'm looking at an automated process (utilizing a "DOS" .BAT file) that creates zip files with a simple command like...
wzzip [path][zip file name] [files to be zipped]
...but when a partner receives and unzips these files, it's creating a folder with the name of the zip file and putting the files inside it, and they need (well, or at least prefer) it to just extract the files to the "." folder.
Is there a way to get wzzip to use "." instead of creating an eponymous folder? The only thing I could see in the options list was to maybe hack something out of -r-p (even though I DON'T actually want it to recurse folders when zipping), but I was hoping there might be a better way.
The partner company is apparently running Linux, so while I see that wzunzip has an option to set the output folder that MIGHT override the default behavior, I'm not sure what the app they are using might allow.

Go to http://www.winzip.com/ and download the Winzip Command Line utilities. Install and use WZZIP.EXE.

Related

Overwrting multiple file using NSIS Script (how Win Zip extractor does)

I am writing a script using Null Script which install around 6000 files in INSTALLDIR i.e. C:\ABC folder.
I have done this using
File /r "ABC"
in install section.
It is just a simple extractor (no registry entries and no uninstall.exe created during install).
Now, if I run the same exe again then I want my exe to display a message box to the user while overwriting the files containing the options
Yes,
Yes too all, or
exit the installer
i.e. How WinZip software does while extracting the same zip file in the same location multiple times.
If I set the SetOverwrite value to off then during install (2nd time) my EXE just skips the file installation without notifying the user. Also using IFFILEEXIST I can check a single file or *.* files but cannot do one to one mapping.
Please suggest how can I implement this. If this question is already posted then please send me the link.
Thanks in advance.
It is not possible to get this behavior in NSIS when using File /r. You might be able to pull off something similar by generating the file list at compile time by executing a batch file with !system and then check if each file exists and maybe delete the old one at run-time but you are not going to get the dialog without a custom plugin. NSIS itself only supports basic Abort/Retry/Cancel and Yes/No dialogs.
If you only want to use free tools, why not just use 7-Zip to create a self extracting archive?

Why would one create an empty file?

I saw the command: touch while watching a video about the Terminal
It was something like:
user$ touch testfile
user$ ls
Documents Photos Music testfile
So I couldn't answer to myself:
Why one would want to create an empty file?
If you can, please make a short list of a few applicabilities of it!
I'll give a practical example of when I just used empty files in Ubuntu a few days ago. I was creating a program in C that could symlink files, directories, and entire directories of files. After I finished all my coding, I made a simple shell .sh script that created a "mock" directory structure. Including empty files and directories so I could test my program symlinking these "fake" files.
This makes it easy to:
Start the test over easily if something isn't working.
Play around with files of no importance (don't want to risk losing actual data).
To represent a collection of information with no instances.
When the mere presence or absence of the file is all that matters
To test if the script works by using a simple test "Subject"
To put Items,Codes and others things in later.
To use it as a example or represent Information.
I use:
touch __init__.py
all the time in a directory I am importing custom python modules, data files (csv, txt, etc), etc. from.
Explanation:
In Python, when one wants to import a module in another folder, the target folder needs an __init__.py file (that can be completely empty).
i.e.
from lib import somefile
And in the directory lib there is a blank file named __init__.py
It can be used for lock files, or when the data you need are in the file name itself. For example, I used to touch a file called "/.MYCOMPUTER_ROOT_2015_AUG_3" (for example) so that when I backed up the root partition on "mycomputer" to tape, I could tell which tape I was reading.
For the paranoid system administrator.
To write a shell script, that executes commands with elevated privileges (as root user for example), on a system with multiple concurrent users, and you want to protect your shell script from accidental (or malicious) usage before you're completely done with it. Then you do:
touch script.sh -> creates an empty file that does nothing and cannot be executed because it doesn't have +x set, so nobody can do anything harmful.
chown and chmod the file, to make sure that only the right users can do anything with it.
and only then you start vi or emacs or nano or whatever to write your very powerful shell script.
If you do the chown/chmod after you have written the file, then someone else could have already done bad things with it.
EDIT: a better example would be a file with SUPER SECRET CREDENTIALS, for example your ~/.aws/credentials file with your aws_secret_access_key.
If you write the credentials in the file first, and then chmod them, then in those few seconds between, someone could steal your file.
If you chmod first before there is any content, then you are safe(r).

Sync folders with xcopy/batch based on checksum?

I'm trying to make a simple batch for windows that will basically sync two folders, the catch is that the files in the folders can be named arbitrarily and the snyc should be based on the checksum. I've only found information about xcopy that compares the timestamp so I'm wondering if this is possible in a simple matter at all.
Here is the scenario I'm trying to manage, you've got the "Import Folder" containing the files named A_2.bmp and A_3.bmp and the "Target Folder" containing file A_1.bmp.
File A_2.bmp is infact the same file as A_1.bmp, just with a different name and thus should be skipped, A_3.bmp should then be copied over to target folder and icrementally renamed to A_2.bmp.
This probably sounds more like a work for patching software, but I'm looking for a solution that doesn't require building patches all the time and is open for the user (so he can just drop files into the import folder and run it whenever the need arises)
If there is software for such a thing that is free and can be distributed without installing I would also consider this a good option, but I haven't found anything.
I'm thankful for any advice and help on this matter so thank you very much for your time and help!
You have this command line utility :
http://www.microsoft.com/en-us/download/details.aspx?id=11533
You can then make a bat who simply test the checksum of the files

Traverse Zipped Filesystem from Command Line

Is there a way to traverse the files & folders inside an archive? For example, if I have a file my-zip-file.zip, could I do
ls -l my-zip-file.zip
or even
cd my-zip-file
I know there are the command tar and the command line version of 7-Zip, but it seems like you can only do these things from outside the archive. Also, with grep, you can pretty much simulate the ls situation from this question, but much slower and, again, only from outside the archive.
With the GUI version of 7-Zip, you can do pretty much all of this, just with a different shell, so I am looking for a command-line version. From this question that I asked, it seems 7-Zip does this by creating temporary folders to hold the represented files & folders, so this might be a bottleneck.
I would like this solution to be cross-platform, but I understand if that's not possible.
Yes, you can effectively mount a zip file on the file system using AVFS.

Batch file to list and copy files to another directory

I'm a novice with batch files, even though I've had a computer since the mid 1980s. I need to create a (preferably simple) batch file that will list all the directories on drive D:\TAR\ (to a text file maybe?) and append the extension .tar to the directories names. Then I would like to copy all the .tar files(in the text file that was created) on E:\Incomplete\File1.tar to F:\ToComplete\ directory.
I tried doing it from a DOS command prompt, but I couldn't figure out how to put the .tar extension on the directory names and do the copying. I've been googleing, and searching on this site, with no similar problems.
Is there a list on the net that list most of the commands that can be used in .bat files, for example #echo, end, if, then, etc.? I would like to be able have it as a guide. I would appreciate any and all help.
Thank You.
The command prompt has a builtin help command that provides a decent listing of common commands, and each command supports the /? switch to attain more information on it.
You will typically use the for command to enumerate the contents of a directory, and if you need to perform string manipulation on the directory entries you will probably find the command prompt's "delayed expansion" feature useful. This feature is off by default, but can be enabled for an interactive session by running cmd /v:on. (Enabling this feature permanently requires a registry setting.)
In terms of your specific problem here, when you say "all the directories under D:\TAR\", would that be a recursive operation?

Resources