param(
	[String]$SourcePath,
	[String]$FileName,
	[String]$Configuration,
	[String]$ProjectName
)

$ArchiveFolderName = "Archiv"
$DestinationPath = "M:\Bibliotheken\Digital Data\DD_Modules\$ProjectName\"
$DestinationFilePath = [IO.Path]::Combine($DestinationPath, $FileName)
$ArchiveBasePath = [IO.Path]::Combine($DestinationPath, $ArchiveFolderName)

if ($Configuration -eq "Release") {
	$DateFolderName = $((Get-Date).ToString('yyyy-MM-dd_hh-mm')) 
	$ArchivePath = [IO.Path]::Combine($ArchiveBasePath, $DateFolderName)
	
	if (!(Test-Path -Path $ArchiveBasePath)) {
		New-Item -Path $ArchiveBasePath -Type Directory
	}
	
	if (Test-Path -Path $DestinationFilePath) {
		if (!(Test-Path -Path $ArchivePath)) {
			New-Item -Path $ArchivePath -Type Directory
		}
		Copy-Item $DestinationFilePath -Destination $ArchivePath
	}

    Copy-Item $SourcePath -Destination $DestinationFilePath
}
