jschuss
 New Member Posts:9

 |
| 25 Aug 2008 03:30 PM |
|
Hi All,
Does anyone know how to get at the PDF version for a directory of PDF files. I need to list these out for an internal customer to comply with Documentum. I've tried the get-metainfo.ps1 that has been posted. Also checking get-method but don't see how I can get to it yet. Any ideas??
Thanks in advance for any help.
Jay |
|
|
|
|
halr9000 PowerShell MVP, Site Admin
 Basic Member Posts:334

 |
|
Shay
 Basic Member Posts:269

 |
| 25 Aug 2008 04:58 PM |
|
How do I find the version info? By right clicking on the 'file | properties' or by opening it in a pdf reader and then do 'file | properties? |
|
Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic |
|
|
jschuss
 New Member Posts:9

 |
| 25 Aug 2008 09:52 PM |
|
Shay/Hal,
Thanks for your responses.
I came up with the line below which worked OK.
dir Y:\*.pdf|select name, @{n="Version";e= {(gc $_ |select-string "%PDF-*").tostring().substring(5,3)}}|ft -auto |
|
|
|
|
Shay
 Basic Member Posts:269

 |
| 25 Aug 2008 10:33 PM |
|
It doesn't work on my PDF directory. |
|
Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic |
|
|
jschuss
 New Member Posts:9

 |
| 25 Aug 2008 10:43 PM |
|
What errors did you get? Should end up with something like this...
Name Version
---- -------
14-010-01.pdf 1.3
14-010-02.pdf 1.3
28-060-03.pdf 1.3
28-057-05.pdf 1.3 |
|
|
|
|
Shay
 Basic Member Posts:269

 |
| 25 Aug 2008 10:49 PM |
|
I only get the name coulmn, for the value I get this error: Select-Object : You cannot call a method on a null-valued expression. It works only if I change 'gc $_ ...' to gc '$_.fullname ...' Plus, it takes ton of time to complete and I have only 6 files in the directory. Check this project, see if can help: http://pdfsharp.com/PDFsharp/ |
|
Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic |
|
|
jschuss
 New Member Posts:9

 |
| 25 Aug 2008 10:58 PM |
|
Not sure why you had to use fullname an I didn't...
There's probably a more efficient way to do it but this got the customers request taken care of.
If I have to do this again I'll probably try to tweak performance.
Are your PDF files large. Since we're using get-content to extract the %PDF part of the file for version I think it makes since that if the files are large it wll take a while. I went through 1806 files in about 15-20 minutes but the files were averaging probably 500K. |
|
|
|
|
Shay
 Basic Member Posts:269

 |
| 25 Aug 2008 11:01 PM |
|
The PDF files I tested were ~5mb. |
|
Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic |
|
|
Shay
 Basic Member Posts:269

 |
| 26 Aug 2008 07:43 AM |
|
I found that if you add the '-totalCount 1' to get-content (instead of reading the entire file) then the command perform much faster. Can you conform that it works on your PDF files:
dir Y:\*.pdf | select name, @{n="Version";e= {( cat $_.fullname -totalCount 1 | select-string "%PDF-*").line.substring(1)}} | ft -auto |
|
Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic |
|
|
jschuss
 New Member Posts:9

 |
| 26 Aug 2008 03:06 PM |
|
Thanks Shay. That's smokin fast now. I didn't catch that the %PDF was in the 1st line of the PDF files. It was taking 15-20minutes before to get through the 1800+ files and now less than a minute:) That's a good one-liner to keep around:) Thanks again for your help. |
|
|
|
|
halr9000 PowerShell MVP, Site Admin
 Basic Member Posts:334

 |
| 26 Aug 2008 03:14 PM |
|
Oh, cool. That's a keeper, Shay. :) Guys, when you come up with solutions like this, don't forget to post them to our script repository ("Scripts" link at the top of this page). |
|
Community Director, PowerShellCommunity.org Co-host, PowerScripting Podcast Author, TechProsaic |
|
|