Skip to content
Snippets Groups Projects
Commit fc54a078 authored by Jürgen Voskuhl's avatar Jürgen Voskuhl
Browse files

Provide unzip/import PS script

parent 79f2b5f8
No related branches found
No related tags found
1 merge request!86planning#1203: Standards
Pipeline #58040 failed
# Import Markdown files from fit-standards folder
#
# Work flow:
# ===========
# Aftermanually downloading the file standards-markdown-files.zip from
# https://git.fitko.de/foederale-it/standardisierungsagenda/standards/-/tree/markdown-files,
# the invocation of this script will perform the following actions:
# - Expand the zip archive
# - Copy md files from /standards-markdown-files/fit-standards/**/**
# into the corresponding folder in your local dev environment
# - Copy an available image file into /public/img/fit-standards/icons in your dev environment
# - Delete all arbitrary files (inluding the zip file itself)
#
# Author/last update: J. Voskuhl, 2023-10-16
#
# The folder containing the zip archive after downloading it
$downloadFolder = 'C:\Users\Jürgen\Downloads\'
# File name of the archive, without extension
$zipFilename = 'standards-markdown-files'
# The root folder of our local information plattform (used to calculate destination folders)
$infoPlatformRoot = 'D:\MyProjects\FITKO\Informationsplattform\Entwicklungsportal\'
# ======================= NO ADJUSTABLE PARTS BELOW THIS LINE! =============================
$sourceFolder = $downloadFolder + 'fit-standards\'
# ***** Process the zip archive *****
$archive = $downloadFolder + $zipFilename + '.zip'
Write-host $archive
$warn = $null
Expand-Archive -Path $archive -Destination $downloadFolder -Force -WarningVariable warn
if($warn.Count -gt 0) {
throw 'The zip file does not exist ($warn)!'
}
remove-item -Path $($sourceFolder) -Recurse -ErrorAction SilentlyContinue
Move-Item -Path $($downloadFolder + $zipFilename + '\fit-standards\' ) -Destination $($sourceFolder) -Force
$destFolder = $infoPlatformRoot + 'content\fit-standards\'
$destFolderImages = $infoPlatformRoot + 'public\img\fit-standards\icons\'
$filters = '*.jpg', '*.png', '*.svg'
$folders = Get-ChildItem -Path $($sourceFolder) -Recurse -Directory -Force -ErrorAction SilentlyContinue | Select-Object BaseName
foreach ($folder in $folders)
{
$newFolder = $destFolder + $folder.BaseName
$mdFile = $folder.BaseName + ".md"
Write-Host $newFolder
New-Item -ItemType Directory -Force -Path $newFolder | Out-Null
Copy-Item -Path $($sourceFolder + $folder.BaseName + "\" + $mdFile) -Destination $($newFolder + "\")
$imageFile = $filters | % { Join-Path $($sourceFolder + $folder.BaseName + "\") $_ } | Resolve-Path
if (-not ([string]::IsNullOrEmpty($imageFile)))
{
Write-Host "copying '$imageFile'..."
Copy-Item -Path $imageFile -Destination $destFolderImages
}
}
# Cleanup
remove-item -Path $archive
remove-item -Path $($downloadFolder + $zipFilename) -Recurse
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment