Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Cannot get XMP metadata for PDF version 1.5 via Powershell

New Here ,
Feb 12, 2023 Feb 12, 2023

I am trying to get XMP metadata from pdf via Powershell, which i am able to get from some docs and not from some.

The only difference is the version .ie 1.6 for which i can get the XMP metadata and 1.5 for which i cannot .The bold text is where it gives me null value.

 

Any help appreciated.

Attached is the code

 

$Directory = "C:\safety_pdf\"

$items = Get-ChildItem -Path $Directory -Recurse -Force
$itemDataCol = @()
ForEach($item in $items){
$a =(Select-String "ModifyDate\>(.*)\<" $($item.FullName)).Matches.Groups
ForEach($group in $a)
{
$itemData = [PSCustomObject]@{

PageID=$item.Name.Split("_")[0]
FileID= $item.Name.Split("_")[1]
Name = $item.Name.Split("_")[2]
CustomisedName = $item.Name
FullName = $item.FullName
SystemModifiedDate = $item.LastWriteTime

#LastsavedDate = (Select-String "ModifyDate\>(.*)\<" $($item.FullName)).Matches.Groups[((Select-String "ModifyDate\>(.*)\<" $($item.FullName)).Matches.Groups).Count-1]
#LastsavedDate = (Select-String "ModifyDate\>(.*)\<" $($item.FullName)).Matches.Groups[0]
LastsavedDate = $group.Value
}
if(-not($itemData.LastsavedDate.Contains("ModifyDate>")))
{

$sub = $itemData.LastsavedDate.Split('T')[0]
$dateformat= $sub.Split('-')
$dd = $dateformat[2] + '/'+ $dateformat[1] + '/' + $dateformat[0]
$itemData.LastsavedDate = [datetime]::parseexact($dd, 'dd/mm/yyyy', $null).ToString('mm/dd/yyyy')
$itemDataCol += $itemData
}
}

}

$itemDataCol| Export-Csv -Path "C:\safety_pdf.csv" -NoTypeInformation -Encoding UTF8

TOPICS
General troubleshooting , How to
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2023 Feb 14, 2023

Does you see the metadata when you open a file in a text editor?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 14, 2023 Feb 14, 2023
Hi,
Yes.I do see the date last saved from the document properties but i get
the object in powershell as empty
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 15, 2023 Feb 15, 2023
LATEST

May be a issue with the content of the files.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines