2

I've got a ZIP file of 32,000 PDF reports that I need to rename to a more descriptive name, plus generate a TXT file of all the files and their sub-folders. I have been using the

dir /b /s >info.txt

command line for some years now, but obviously this just gives what the current file name is. However, when I move the mouse over the file, I get the full title, author, etc. When I right click on one of the files that information is in the PDF tab, not in the Summary tab.

So - my question is how can I rename these files to the title that is in the Title field, allowing me to scan through the list quickly and easily?

Thanks Chris

Yossi
  • 11,778
  • 2
  • 53
  • 66
user2337160
  • 41
  • 1
  • 5
  • 2
    I doubt that can be done from a plain batch file/command. If you are willing to use powershell or wscript: http://blogs.technet.com/b/heyscriptingguy/archive/2008/08/13/how-can-i-find-files-metadata.aspx – rene Apr 30 '13 at 18:59
  • 1
    I'm not sure, but WMIC may be able to help? See http://superuser.com/questions/363278/is-there-a-way-to-get-file-metadata-from-the-command-line – Nate Hekman Apr 30 '13 at 19:17
  • Thanks Rene / Nate - Unfortunately I have very limited users rights on my PC at work and because the information is highly confidential I can't bring it home to work on. I was hoping to be able to do this through a Batch, but obviously it won't work. Is there something that can be done in VBA or even VB.NET (I have 2005) that could do what I need? Thanks again :-) – user2337160 May 02 '13 at 13:37

1 Answers1

0

Here is a way to do it using PDFTK

@echo off
setlocal

set "pdftk=c:\Program Files\PDF Labs\PDFtk Server\bin\pdftk.exe"
set "pdfs=C:\PDFS"
set "rep=%temp%\rep.txt"

for /f "tokens=*" %%a in ('dir %pdfs%\*.pdf /s /b /a-d') do (
  if exist %rep% del %rep%
  "%pdftk%" "%%a" dump_data output "%rep%"
   for /f "tokens=1,2* delims=: " %%b in ('findstr /n .* %rep%') do (
      if "%%b" equ "6" echo(ren "%%a" "%%d.pdf"
   )    
  pause
 )

Change the file paths as appropriate to your environment. This will echo what the rename command will be to the screen. If all looks well, remove the echo( from in front of the ren to actually do the operation. Also, I added a pause in the loop because you have so many files it would fill your screen buffer in a few seconds. When you're ready to go, just remove it.

Matt Williamson
  • 6,947
  • 1
  • 23
  • 36