Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://stackoverflow.com/a/57494414/5079799

Folder:

Function Get-Folder($initialDirectory) {
    [void] [System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
    $FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog
    $FolderBrowserDialog.RootFolder = 'MyComputer'
    if ($initialDirectory) { $FolderBrowserDialog.SelectedPath = $initialDirectory }
    [void] $FolderBrowserDialog.ShowDialog()
    return $FolderBrowserDialog.SelectedPath
}
$Folder = Get-Folder
Write-Host "Folder = $Folder"
#$Folder = Get-Folder
$Folder = "C:\tmp"

$Files = @(Get-ChildItem -Path "$Folder\*.pdf")
$Files | ForEach-Object {
$FileFound = "False"
$FileFound = $_.Name -match '^\w\wd\d.pdf$'
 If ($FileFound -eq "True") {
  $FileName = [System.IO.Path]::GetFileNameWithoutExtension($_)
  Write-Host $FileName
 }
}
  • No labels