janikvonrotz
2/6/2014 - 12:16 PM

PowerShell: Handle not existing file paths or filenames from a unspecific path #PowerShell

PowerShell: Handle not existing file paths or filenames from a unspecific path #PowerShell

$PathAndFilename = Get-PathAndFilename $Path

if(-not $PathAndFilename.Filename){$PathAndFilename.Filename =$AlternativeFilename}
if(-not $PathAndFilename.Path){$PathAndFilename.Path = (Get-Location).Path}
if(-not (Test-Path $PathAndFilename.Path)){New-Item -Path $PathAndFilename.Path -ItemType Directory}
$Path = Join-Path $PathAndFilename.Path ($PathAndFilename.Filename)