Obrigado por todos os comentários. Aqui está o meu código para renomear um arquivo pdf do seu respectivo texto ou metadados. O código é altamente primitivo porque não sou um homem de TI; apenas emprestado e juntou peças de outros.
$x = @() function Read-OpenFileDialog([string]$WindowTitle, [string]$InitialDirectory, [string]$Filter = "All files (*.*)|*.*", [switch]$AllowMultiSelect) { Add-Type -AssemblyName System.Windows.Forms $openFileDialog = New-Object System.Windows.Forms.OpenFileDialog $openFileDialog.Title = $WindowTitle if (![string]::IsNullOrWhiteSpace($InitialDirectory)) { $openFileDialog.InitialDirectory = $InitialDirectory } $openFileDialog.Filter = $Filter if ($AllowMultiSelect) { $openFileDialog.MultiSelect = $false } $openFileDialog.ShowHelp = $true # Without this line the ShowDialog() function may hang depending on system configuration and running from console vs. ISE. $openFileDialog.ShowDialog() > $null if ($AllowMultiSelect) { return $openFileDialog.Filenames } else { return $openFileDialog.Filename } } $file = Read-OpenFileDialog -WindowTitle "PDF Dosyası seçin" -InitialDirectory '$path' -Filter "PDF files (*.pdf)|*.pdf" if (![string]::IsNullOrEmpty($file)) { Write-Host "You selected the file: $file" } else { "Dosya seçmediniz" } $path= "$file"|Split-Path cd $path [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") $objForm = New-Object System.Windows.Forms.Form $objForm.Text = "VERİ FORMU" $objForm.Size = New-Object System.Drawing.Size(700,400) $objForm.StartPosition = "CenterScreen" $objForm.KeyPreview = $True $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") { $x=$objListbox.SelectedItem;$objForm.Close() } }) $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}}) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(75,220) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "EVET" $objForm.Controls.Add($OKButton) $OKButton.Add_Click({$x=$objListbox.SelectedItem;$objForm.Close()}) $CancelButton = New-Object System.Windows.Forms.Button $CancelButton.Location = New-Object System.Drawing.Size(200,220) $CancelButton.Size = New-Object System.Drawing.Size(75,23) $CancelButton.Text = "İPTAL ET" $CancelButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($CancelButton) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(10,20) $objLabel.Size = New-Object System.Drawing.Size(480,20) $objLabel.Text = "LİSTEDEN SEÇİM YAPIN:" $objForm.Controls.Add($objLabel) $objListbox = New-Object System.Windows.Forms.Listbox $objListbox.Location = New-Object System.Drawing.Size(10,40) $objListbox.Size = New-Object System.Drawing.Size(600,840) $objListBox.Font = "Arial Black" pdftotext -eol dos -l 2 $file tmp.txt (gc tmp.txt) | ? {$_.trim() -ne "" } | set-content tmp.txt $i=pdfinfo "$file" |grep -i title|sed -e 's/Title\:[ ]*//g' If (![string]::IsNullOrEmpty($i)) { $line6=$i } $line1= (Get-Content tmp.txt)[0] $line2= (Get-Content tmp.txt)[1] $line3= (Get-Content tmp.txt)[2] $line4= (Get-Content tmp.txt)[3] $line5= (Get-Content tmp.txt)[4] [void] $objListbox.Items.Add("$line1") [void] $objListbox.Items.Add("$line2") [void] $objListbox.Items.Add("$line3") [void] $objListbox.Items.Add("$line4") [void] $objListbox.Items.Add("$line5") [void] $objListbox.Items.Add("$line6") $objListbox.Height =170 $objForm.Controls.Add($objListbox) $objForm.Topmost = $True $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog() $z= $objListbox.SelectedItems if ($z -ne ""){ $z= $z -replace '[^a-zA-Z0-9_ ]',"_" $z= $z -replace '[ ]',"_" $z= $z -replace '_{2,}',"_" $z= $z.Trim() Write-Host "dosya $z.pdf olarak kaydedildi" rename-item $file -newname $z".pdf" } Else {Write-Host "isim değişmedi"} rm tmp.txt pause $x