DO10: Automatically creating an archive like an JAR

Hello,

a complex requirement:
[ol]
[li]I have an folder selected with an relative path like
..\MainFolder\FolderFiles[/li]
[li]I want to create an archive with the content of that folder (all files/subfolders)
..\MainFolder\FolderFiles
The name of that archive should be
MainFolder[/li]
[li]The archive should then be saved in folder
..\MainFolder\FolderArchive
The name of FolderArchive is fixed (just a string).[/li][/ol]
My main problem is to get the MainFolder-string (second last part of the path). Is that possible at all?

Many thanks and greetings
opusfreak

You can use {sourcepath|..|nopath|noterm} to get the name of the parent of the current path, or {sourcepath|....|nopath|noterm} to get the name of the grandparent.

Hello Leo,

many thanks. What is wrong with that code:

@set ArchiveFileName {sourcepath|..|noterm}\FolderArchive\{sourcepath|..|nopath|noterm}.ArchiveExt {dlgstring|Test|{$ArchiveFileName}} Copy ARCHIVE CreateFolder={$ArchiveFileName}
The filepath with filename is correct (checked via the dialog), but got an error that the file can't be found??

Many thanks and greetings
opusfreak

What is .ArchiveExt ?

It will probably fail if there are spaces in the path - try putting quotes around the variable:

Copy ARCHIVE CREATEFOLDER "{$ArchiveFileName}"

Hello,

@Leo: .ArchiveExt is the extension of the archive. It's a zip archive, but with another extension (like e. g. .jar). At the moment I'm testing without the extension, so a .zip should be created.
@Jon: No spaces in the path. Tried it already with quotes.

Without any given path, just a name without extension (and with extension) the archive is created and moved in the active dest lister folder.
I really have no glue why that simplified example doesn't work:

@set ArchiveFileName {sourcepath}Test.zip {dlgstring|Test|{$ArchiveFileName}} Copy ARCHIVE CREATEFOLDER "{$ArchiveFileName}" ArchiveFileName contains a valid path with filename.

Many thanks and greetings
opusfreak

You're getting an error because your {dlgstring| ... } line is will try to run the name of the archive, which isn't a command.

This seems to work and do all of what you wanted in the original post:

@nofilenamequoting Copy * ARCHIVE=.zip TO "{sourcepath|..}FolderArchive" CREATEFOLDER "{sourcepath|..|nopath|noterm}"

Hello Leo,

again many thanks. That was difficult, wasn't it?

Greetings
opusfreak

Hello,

last question: I want to replace/overwrite the already existing archive. What must I add to the code?

@nofilenamequoting Copy * ARCHIVE=.zip TO "{sourcepath|..}FolderArchive" CREATEFOLDER "{sourcepath|..|nopath|noterm}"

Many thanks and greetings
opusfreak

With zip files it'll prompt you for whether you want to merge or replace the existing archive; just choose Replace when prompted.

If you don't want to be prompted:

@nofilenamequoting Delete QUIET "{sourcepath|..}FolderArchive\{sourcepath|..|nopath|noterm}.zip" Copy * ARCHIVE=.zip TO "{sourcepath|..}FolderArchive" CREATEFOLDER "{sourcepath|..|nopath|noterm}"