header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Get PDF version of files
Last Post 26 Aug 2008 03:14 PM by halr9000. 11 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
jschussUser is Offline
New Member
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

halr9000User is Offline
Basic Member
Basic Member
Posts:316

--
25 Aug 2008 04:54 PM  
I've been searching the net and so far no luck...Maybe somebody else can find something.
ShayUser is Offline
Basic Member
Basic Member
Posts:228

--
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?

jschussUser is Offline
New Member
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

ShayUser is Offline
Basic Member
Basic Member
Posts:228

--
25 Aug 2008 10:33 PM  
It doesn't work on my PDF directory.
jschussUser is Offline
New Member
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  

ShayUser is Offline
Basic Member
Basic Member
Posts:228

--
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/
jschussUser is Offline
New Member
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.

ShayUser is Offline
Basic Member
Basic Member
Posts:228

--
25 Aug 2008 11:01 PM  
The PDF files I tested were ~5mb.
ShayUser is Offline
Basic Member
Basic Member
Posts:228

--
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

jschussUser is Offline
New Member
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.
halr9000User is Offline
Basic Member
Basic Member
Posts:316

--
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).
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer