Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zip folder #3

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# CWTS ETL tooling
Version: 8.0.0
Version: 8.1.0

## Description

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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'**

Expand Down
22 changes: 21 additions & 1 deletion functions/zip_folder.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
:: =======================================================================================