diff --git a/README.md b/README.md index 290bb7a..8cdf08d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # CWTS ETL tooling -Version: 8.0.0 +Version: 8.1.0 ## Description @@ -72,7 +72,7 @@ When writing new pipeline code or ETL-tooling functions, the `functions\variable | `xml_generate_prg` | v2.0.0 | | `xml_parse_data` | v1.0.2 | | `xml_split_data` | v1.0.2 | -| `zip_folder` | v2.0.0 | +| `zip_folder` | v2.1.0 | ### add_extended_properties @@ -363,6 +363,9 @@ When writing new pipeline code or ETL-tooling functions, the `functions\variable ### zip_folder +- v2.1.0 + - add optional global parameter `zip_include_directory` + - add optional global parameter `zip_append` - v2.0.0 - **add argument 'zip_log_folder'** diff --git a/functions/zip_folder.bat b/functions/zip_folder.bat index a42b626..4b95b4b 100644 --- a/functions/zip_folder.bat +++ b/functions/zip_folder.bat @@ -6,6 +6,12 @@ ::: To capture this output and use it as a conditional in a pipeline-script, ::: use: `if not errorlevel 0 (...)` +:: Global variables +::: zip_include_directory: if set to true, this script will include the name +::: of the source folder in the archive. +::: zip_append: if set to true, this script will add to an existing zip file if it exists. +::: otherwise the existing zip file will be deleted beforehand. + :: Input variables ::: 1. source_folder: folder containing the data to be compressed ::: 2. target_file: name for the target zip file (with path and extension) @@ -29,7 +35,7 @@ set zip_log_folder=%~3 call :check_variables 3 %* echo Creating %target_file% -"%zip_exe%" a "%target_file%" "%source_folder%\" -mmt=16 -mx=1 -y -bsp0 -bso0 -bse1 > "%zip_log_folder%\compress_%target_file_name%.error" +"%zip_exe%" a "%target_file%" "%source_folder%" -mmt=32 -mx=5 -y -bsp0 -bso0 -bse1 > "%zip_log_folder%\compress_%target_file_name%.error" echo Validating %target_file% "%zip_exe%" t "%target_file%" > nul 2>&1 @@ -68,6 +74,20 @@ call %functions_folder%\variable.bat :create_folder target_folder call %functions_folder%\variable.bat :check_variable target_file_name call %functions_folder%\variable.bat :check_extension target_file zip call %functions_folder%\variable.bat :create_folder zip_log_folder +call %functions_folder%\variable.bat :default_variable zip_include_directory false +call %functions_folder%\variable.bat :default_variable zip_append false + +if "%zip_include_directory%" == "true" ( + set source_folder=%source_folder%\ +) else ( + set source_folder=%source_folder%\* +) + +if "%zip_append%" NEQ "true" ( + if exist "%target_file%" ( + del %target_file% >nul + ) +) goto:eof :: =======================================================================================