Copy ZIP

How do I create a button to ZIP a set of directories into a single ZIP file, which I then copy to another drive? I tried various combinations of "Copy", "ADDTOZIP", "ZIP" and "TO" but it only seems to ZIP into the target directory rather than into the file of my choice.

Copy ADDTOZIP HERE will create the zip in the source directory instead of in the destination directory.

Is that all you need, or something extra as well?

(By the way, when you're prompted for the name/path of the zip file, it looks like you can type over the full path with just a filename and it'll still be created in the current directory, at least with the HERE argument. Saves a bit of time.)

You can avoid being prompted for a name at all by hard-coding the zip file name into the button. You could use a date string so that the files are put into a zip named after today's date. Useful for doing backups. If you want to know how just shout and I'll play around and post a command.

I want to copy the contents of some random directories into a single ZIP file. I just tried:

Copy "C:\Documents and Settings\me\Application Data\GPSoftware\Directory Opus" ADDTOZIP

and

Copy "C:\Documents and Settings\me\Application Data\GPSoftware\Directory Opus" ADDTOZIP "C:\Backup.zip"

Both commands just create an empty zip file and return an error saying "The system cannot find the path specified."

I want to specify all the paths in the button, both the source directories and the name of the zip file.

So far I've got

[b]Copy "C:\Documents and Settings\Leo\Desktop" ZIP TO C:[/b]

which will zip the Desktop folder into C:\Desktop.zip. So that's everything except the zip file always ends up with the same name as the directory.

I could swear I managed to do this in the past, though... Can anyone see what I'm missing? I'm writing this after very little sleep so I'll have another look later on. :slight_smile:

Maybe with AS ? Not sure, would have to check, and dinner is ready :slight_smile:

I tried AS but couldn't get it to work. Maybe there's a way, though.

Doing Copy ZIP AS HERE actually seems to cause the AS argument to operate on how the selected files and folders are (re)named when 'copied' into the zip file... the zip file itself is still auto-named (as per the documentation) based on the first selected item being zipped.

This was the only way I could get this idea to work... TOTAL hack:

sync:dopusrt /cmd Clipboard COPY
sync:dopusrt /cmd CopyToZip "{Rs|Specify new name for zipfile|{s}}"
sync:dopusrt /cmd Clipboard PASTE
sync:dopusrt /cmd Go BACK

where CopyToZip is a 'user' command defined as:
template = zipfile
function = CreateFolder READAUTO ZIP NAME="&zipfile&"

I'd say there are two areas of enhancement needed in Opus to do what we're talking about doing in a less klugey manner...

  1. It would seem we should be able to specify the zip filename in one or the other of the ZIP/ADDTOZIP Copy options... i.e. Copy ADDTOZIP=filename.zip.

  2. Given that Opus zip support allows us to deal with zip files as folders, it would seem logical to be able to perform an otherwise normal copy operation of selected files/folders to an existing zip file... the series of commands above paste the clipboard contents into the zip file while it is opened as a folder... why not allow the single command suggestion above to 'add' the files to the zip archive if the specified filename already exists?

NOTE- it seems Copy ADDTOZIP=filename.zip uses the filename after the "=" but still prompts for compression level, password, etc... PLUS the resulting zip file is empty. The Copy ZIP option ignores the "=" and still names the file after the first selected item :frowning:. Tantalizingly close :slight_smile:.

Hi Steje !

Funny Steje, I have a slightly different take on this problem.
I've been aware of it for some time and coincidentally looked into it a bit more today.

I've been attempting to simply to create a zipfile with the same name as a selected folder.
However, I want the folder itself inside the zip file.
In other words, I don't want to zip the folder, I want to create a new zipfile of the same name and move the folder into it.

I've been using

Go TABDUPLICATE SELECT HIDEUNSEL NoPattern Copy Move ADDTOZIP Here

It prompts for compression level, password, etc..., but in my case as there is only one folder, the default name is correct and I just press OK.

I made a 4NT batch file of your
dopusrt /cmd CopyToZip "{Rs|Specify new name for zipfile|{s}}"
and asked in the next line of the 4NT batch file if the file existed.
It did ! Your hack may really work !

I then use another button to keep the resultant zip file visible and selected.

Select All Select ShowHidden NoPattern Select Prev Select Next MakeVisible

:opusicon: porcupine

Don't know if you'r estill watching this thread but, just in case (and as I found it while searching for something else), you might like to know that Opus 9.0.0.1 has added an improvement to the Copy ZIP/ADDTOZIP which should make what you wanted to do very easy:

[ul][li]...[/li]
[li] The Copy ZIP and ADDTOZIP commands can now accept the CREATEFOLDER argument to specify the name of the destination Zip file[/li]
[li]...[/li][/ul]