Functional Overview
This Button enables the user to extract selected archives, with the option to delete the archives after extraction. Thereby it will create a target subfolder if the archive contains not only a single folder on the first level.
- It supports all the archive types that DOPUS supports.
- The button remains disabled unless the user select at least one archive file.
- The button will create target subfolders for the cases where the archive contains more than one folder on the first level.
- The user can choose in dual display mode if the archive(s) shall be extracted to the source or destination pane, with options for deleting the original archive(s) and handling the case where the target folder already exists.
- In single display mode the button automatically renames an existing target folder and prompts the user to keep or delete the original archive after extraction.
- The button will initially ask for all necessary passwords, so that the extraction can be unattended (as long as it was chosen to delete all or no archives at all after extraction).
Detailed description how the button works
- In dual display mode a dialog ask the user where to extract (source or destination pane), how to treat existing target folders and if the archives shall be deleted after extraction.
- As first step all selected items are analysed and a decision is made how to proceed for each item in the second step.
- Non-archive items will be skipped in the second step.
- Damaged archives (no access possible at all) will be skipped in the second step.
- For encrypted archives the password dialog will be forced. If you enter the correct password the archive will be extracted without password dialog in the second step.
- One exception: If the file names are not encrypted and the archive contains only folders and empty files this archive will be skipped (its not possible to force the password dialog in this case and that seems to be also only a theoretical case).
- If you cancel the password dialog the archive will be skipped in the second step.
- For archives without encrypted file names DOpus does currently not mention the archive name in die password dialog. If you are unsure for which archive the password is requested you can open the script log at the bottom of the DOpus window and there will be written for which archive the password dialog is open.
- For all archives with access it is analysed if there are multiple items or only a single folder on the first level and whether the single folder is unique above all selected archives (without the skipped ones).
- If there are multiple items on the first level the archive will be extracted later into a folder named after the archive.
- If there is only one folder on the first level and this folder is unique about all selected archives with one folder on the first level, the archive will be extraced in the second step directly (so there will be no single folder in a folder).
- If there is only one folder on the first level and this folder is not unique about all selected archives with one folder on the first level, the archive will be extraced in the second step into a folder with the name “archivename_foldername”.
- As second step the extraction starts and can be unattended (at least as long no error occurs and it was chosen to delete all or no archives after extraction)
- Each archive will be extracted according to the rules mentioned above
- If the target folder already exist the existing folder
- will be renamed in single display mode with the suffix “current date and time”.
- will be treated in dual display mode like the user has defined it in the initial dialog.
- According to the users choise the archive will be deleted after extraction if the encryption did not fail.
- Archives which were “marked” as to be skipped in the first step will not be deleted.
- As third and last step a text file will be created in a temporary folder and opened automatically if there is something relevant to report. This text file will be deleted after 10 minutes (earliest).
Explanation regarding subfolder creation
If the archive contains only one folder on the first level and this single folder name is unique above all selected archives
Root
...└─archive.zip
..........└─single folder
the button script will extract the archive directly under the root folder:
Root
...├─single folder
...└─archive.zip
..........└─single folder
If the archive contains only one folder on the first level and this single folder name is not unique above all selected archives
Root
...├─archive_1.zip
....|.....└─folder_1
...└─archive_2.zip
..........└─folder_1
the button script will extract each archive into a folder named after archiv and sub folder:
Root
...├─archive_1_folder_1
...├─archive_2_folder_1
...├─archive_1.zip
....|.....└─folder_1
...└─archive_2.zip
..........└─folder_1
If the archive contains several items on the first level
Root
....└─archive.zip
...........├─folder 1
...........├─folder 2
...........└─readme.txt
the Button script will create a new folder named after the archive and extract the archive into this new folder:
Root
...├─archive
....|.....├─folder 1
....|.....├─folder 2
....|.....└─readme.txt
...└─archive.zip
..........├─folder 1
..........├─folder 2
..........└─readme.txt
Included language overlays
- English
- German
- French
How to Install
- Simply drag and drop the dcf file onto an appropriate toolbar. See also How to use buttons and scripts from this forum
- If the button is never enabled you have to edit the second line in the code. Replace it with following code:
@disablenosel:type=grp:Archives
If you are not using English as GUI language you have to replace "Archives" with the corresponding name in your language (In German it is "Archive").
How to change the default behavior
-
If you want to change the default setting (pre-selection) for dual display mode and the case, that a target folder already exist you have to change the numerical value in the script line
Dlg.Control("combo1").SelectItem(0);
(currently row 39) to one of the values mentioned above this line. -
If you want to change the default setting (pre-selection) of the archive-deletion for dual display mode you must change this via the dialog editor for the dialog “destination” (or directly in the code).
-
If you want to change the default setting of the archive-deletion dialog, which appears for single display mode and for dual display mode if "Delete-query for each archive" was chosen you must change this via the dialog editor for the dialog “delete”.
-
The default setting regarding handling of existing target folders for single display mode can only be changed directly in the code via rewriting/copy the wanted behavior from the dual display section.
How to Use
Available options for the case that a target folder already exists (only dual display mode)
-
Rename the old folder (default / pre-selected)
The existing folder will be renamed and afterwards the archive will be extracted into a new created folder -
Replace the old folder
The existing folder will be deleted to the recycle bin (at least if you did not change the global setting that the recycle bin will not be used) and afterwards the archive will be extracted into a new created folder -
Skip the archive
The archive that has the same name as an already existing folder will be skipped. This archive will not be deleted no matter which delete-option was chosen in any dialog. -
Skip same-named files
The archive will be extracted into the already existing folder and when there is a conflict due to same-named files the old file will be kept. -
Replace same-named files
The archive will be extracted into the already existing folder and when there is a conflict due to same-named files the old file will be overwritten.
-
Select the archives which shall be extracted and press the button
a. Dual display mode:- Choose an option for the case where a target folder already exists
- Choose a delete option (the default selection is “delete all archives”)
- Choose to extract the archives to the source or destination pane.
b. Single display mode:
- The script directly extracts the archives to the source pane. If a target folder already exists it will rename the existing folder before extraction.
-
When you have chosen in dual display mode “Delete-queryfor each archive” or you are using the single display mode a dialog box will be displayed which offers the option to delete the currently processed archive:
-
If there is something to report a text file with information about that is created and opened. This text file will be deleted after 10 minutes (earliest).
Credits
I adapted this Button from freds “Smart Archive Extraction”. See Smart archive extraction
A big thank you to @fred.
Based on a user request for a function that the archive are deleted after extraction I started to change the script and then developed it further. So I created a new topic after alignment with fred.
Thanks to @onedot3 for testing the button script a lot.
Thanks to @khalidhosain for the hint regarding the deletion of archives although the extraction failed or the archives are encrypted (but not successfully extracted).
Further Development
Please share any problems or ideas that could improve this Button.
Button Download
Warning : Only for DOpus v12.22 and higher.
V1.0.223
Extract.dcf (37.4 KB)
V1.0.224
Extract.dcf (37.2 KB)
- Corrections for the French localisation
V1.0.525b (not fully tested, but should work correctly)
Extract.dcf (39.8 KB)
- Encrypted archives and archives were the extraction fails will never be deleted
V1.1.531
Extract.dcf (44.5 KB)
- The script checks if the archive is encrypted
- The script checks if the encryption was successfull (but will not recognize the failed extraction if a password dialog box is skipped/canceled.)
- Archives which are encrypted or where the extraction failed will not be deleted if "delete all archives" or "yes for all" in the dialog boxes were chosen.
- The last dialog box, which informed about changed folders or skipped items is replaced by a txt file, which is created in a temporary folder and automatically deleted after 10 minutes (earliest).
- This text file is only created when an item was not an archive, existing target folders were changed, an extraction failed or an archive was encrypted, but not deleted (and "delete all" was chosen).
V2.0
Extract_V2.0.dcf (45.8 KB)
- Most of the code is rewritten
- The script analyses now in a first step all selected items, ask for the passwords for encrypted archives and considers non-unique single sub folders.
- The encryption process can be unattended (as long as it was chosen to delete all or no archives after extraction).
- Encrypted archives will also be deleted if that is the users choise as long as the encryption was successfull.