Page 1 of 2
Batch rename PDF files using metadata?
Posted: 25 Mar 2012 09:33
by perseid
Hi, I have a bunch of PDF books that I want to batch rename according to their metadata info (for example "Title_Author_Year_Edition.pdf"). Can this be done with XYplorer? If so, how? Thanks
Re: Batch rename PDF files using metadata?
Posted: 25 Mar 2012 12:36
by highend
Don't know if the script command "property" is aware of the different .pdf fields but if that's not the case you can easily write a script for your kind of task and use exiftool (
http://www.sno.phy.queensu.ca/~phil/exiftool/) to get the properties that you need for the renaming process.
Re: Batch rename PDF files using metadata?
Posted: 25 Mar 2012 20:32
by serendipity
perseid wrote:Hi, I have a bunch of PDF books that I want to batch rename according to their metadata info (for example "Title_Author_Year_Edition.pdf"). Can this be done with XYplorer? If so, how? Thanks
Hi an Welcome!
Can you run the below script and see if you the information you need?
http://www.xyplorer.com/xyfc/viewtopic. ... 261#p67261
To run a script, copy paste code into Scripting>Run Script.
Let us know what info you see, based on that you can do batch rename.
Re: Batch rename PDF files using metadata?
Posted: 25 Mar 2012 21:34
by highend
@serendipity
That script doesn't show any of the information the op wants to use (that's what I've tested first, before I proposed exiftool).
Re: Batch rename PDF files using metadata?
Posted: 25 Mar 2012 21:49
by serendipity
highend wrote:@serendipity
That script doesn't show any of the information the op wants to use (that's what I've tested first, before I proposed exiftool).
Really? On my PDFs i can see atleast title, author and year. If i know what the ID is its easy to get the information. I'll find out.
Re: Batch rename PDF files using metadata?
Posted: 25 Mar 2012 22:57
by highend
Really? On my PDFs i can see atleast title, author and year.
Script (full output):
Access = 31.01.2012 19:56:12
Attrib = A
Attributes = A
Create = 31.01.2012 19:56:12
Directory = .eBooks
Name = AutoIt leicht gemacht.pdf
Owner = UK-DT-01\Highend
Size = 616648
Type = PDF File
Write = 31.01.2012 19:55:58
Wheras exiftool shows (ripped output):
Title : AutoIt leicht gemacht
Author : Johannes Mitlmeier
Create Date : 2010:09:29 22:29:21+02:00
etc.
Re: Batch rename PDF files using metadata?
Posted: 25 Mar 2012 23:28
by serendipity
highend wrote:Really? On my PDFs i can see atleast title, author and year.
Script (full output):
Access = 31.01.2012 19:56:12
Attrib = A
Attributes = A
Create = 31.01.2012 19:56:12
Directory = .eBooks
Name = AutoIt leicht gemacht.pdf
Owner = UK-DT-01\Highend
Size = 616648
Type = PDF File
Write = 31.01.2012 19:55:58
Wheras exiftool shows (ripped output):
Title : AutoIt leicht gemacht
Author : Johannes Mitlmeier
Create Date : 2010:09:29 22:29:21+02:00
etc.
OK, I realized i did not upload my v2 script. could you try this script? There are some duplicate items but you should see author, title and date atleast.
Properties-v2.xys
Re: Batch rename PDF files using metadata?
Posted: 25 Mar 2012 23:47
by highend
There are some duplicate items but you should see author, title and date atleast.
Nope
Output:
Access = 31.01.2012 19:56:12
Attrib = A
Attributes = A
Create = 31.01.2012 19:56:12
Directory = .eBooks
Name = AutoIt leicht gemacht.pdf
Owner = UK-DT-01\Highend
Size = 616648
Type = PDF File
Write = 31.01.2012 19:55:58
#1 = 602 KB
#2 = PDF File
#3 = 31.01.2012 20:55
#4 = 31.01.2012 20:56
#5 = 31.01.2012 20:56
#6 = A
#9 = Dokument
#10 = UK-DT-01\Highend
#11 = Dokument
#19 = Nicht bewertet
#53 = UK-DT-01 (dieser Computer)
#155 = AutoIt leicht gemacht.pdf
#173 = Nein
#176 = .eBooks
#177 = D:\Users\Highend\Downloads\.eBooks
#178 = .eBooks (D:\Users\Highend\Downloads)
#180 = D:\Users\Highend\Downloads\.eBooks\AutoIt leicht gemacht.pdf
#182 = PDF File
#188 = Nicht aufgelöst
#269 = Nicht freigegeben
Win 7 x64 SP1 Ultimate, German.
Re: Batch rename PDF files using metadata?
Posted: 25 Mar 2012 23:56
by serendipity
highend wrote:There are some duplicate items but you should see author, title and date atleast.
Nope
OK, thanks for checking. probably something to do with German OS i guess, because i see #20 as author here and lot of other fields do appear.
Maybe OP could check this and see what he/she sees.
On my OS (Win7 32-bit english) i could replicate the batch rename OP was referring to.
Was just hoping that one need not have to go through 3rd party solutions when XY offers one.
Re: Batch rename PDF files using metadata?
Posted: 26 Mar 2012 00:02
by highend
Was just hoping that one need not have to go through 3rd party solutions when XY offers one.
Sure, I'll always try to solve that with in build functions as well (if applicable). The problem is: the technique
to get the properties depends to much on OS version, architecture and language and is (imho) therefore
not a reliable way to get all these informations.
That's why I looked for an external application

Re: Batch rename PDF files using metadata?
Posted: 26 Mar 2012 07:57
by perseid
Hi! First of all let me thank you all for your replies. I have no knowledge in writing scripts and I know the best path is to learn but I need to solve the issue at hand now and I appreciate your sending me the scripts. Also, I'm running Windows XP SP3 32bit (US-English).
I ran the scripts in XYplorer and below you can see the results I got. Now, as you can see below, the script will show in a popup window the Title and Author fields for the selected PDF (among other things) within the XYplorer program. But then the question is, what is the procedure to batch rename say 20 selected PDF's so that XYplorer extracts info from the script results window and renames files accordingly? (for example <Title>_<Author>.pdf)? Thanks
serendipity wrote:
Can you run the below script and see if you the information you need?
http://www.xyplorer.com/xyfc/viewtopic. ... 261#p67261
To run a script, copy paste code into Scripting>Run Script.
Let us know what info you see, based on that you can do batch rename.
This is what I see:
Access = 3/25/2012 4:50:28 PM
Attributes = A
Create = 3/25/2012 4:50:28 PM
Directory = G:\New Folder
DocAuthor = Matt Hendrick
DocTitle = Greek History, 1st Edition
Name = Gh918.pdf
Owner = HP-927838929
Size = 82528991
Type = Adobe Acrobat Document
Write = 2/11/2012 2:24:42 AM
serendipity wrote:OK, I realized i did not upload my v2 script. could you try this script? There are some duplicate items but you should see author, title and date atleast.
Properties-v2.xys
This is what I see:
Access = 3/25/2012 4:50:28 PM
Attributes = A
Create = 3/25/2012 4:50:28 PM
Directory = G:\New Folder
DocAuthor = Matt Hendrick
DocTitle = Greek History, 1st Edition
Name = Gh918.pdf
Owner = HP-927838929
Size = 82528991
Type = Adobe Acrobat Document
Write = 2/11/2012 2:24:42 AM
#1 = 41,523 KB
#2 = Adobe Acrobat Document
#3 = 2/26/2012 3:21 PM
#4 = 3/25/2012 1:50 AM
#5 = 3/25/2012 1:50 AM
#6 = A
#7 = Online
#8 = HP-927838929
#9 = Matt Hendrick
#10 = Greek History, 1st Edition
Re: Batch rename PDF files using metadata?
Posted: 26 Mar 2012 09:40
by j_c_hallgren
perseid wrote:Hi! First of all let me thank you all for your replies. I have no knowledge in writing scripts and I know the best path is to learn but I need to solve the issue at hand now and I appreciate your sending me the scripts. Also, I'm running Windows XP SP3 32bit (US-English).
Hi and welcome to the XY forums!
Knowing what OS you're on helps as answer can vary based on that.
But then the question is, what is the procedure to batch rename say 20 selected PDF's so that XYplorer extracts info from the script results window and renames files accordingly? (for example <Title>_<Author>.pdf)? Thanks
We understand your situation of wanting to get problem solved but before attempting to provide the actual solution, the other posters have first attempted to determine what they have available to work with..now that they have that info, I'm sure they will provide the rest of the answer.
Re: Batch rename PDF files using metadata?
Posted: 26 Mar 2012 10:08
by highend
I'm sure they will provide the rest of the answer
Really? *g*
Code: Select all
$SelectedItems = get("SelectedItemsPathNames", "|");
foreach($Item, $SelectedItems, "|") {
$Title = property("DocTitle", "$Item");
$Author = property("DocAuthor", "$Item");
$NewName = "$Title" . "_" . "$Author";
rename b, "$NewName", p, "$Item";
}
This _should_ work but test it with a few copies of your files before.
Re: Batch rename PDF files using metadata?
Posted: 26 Mar 2012 17:22
by serendipity
highend wrote:I'm sure they will provide the rest of the answer
Really? *g*
Code: Select all
$SelectedItems = get("SelectedItemsPathNames", "|");
foreach($Item, $SelectedItems, "|") {
$Title = property("DocTitle", "$Item");
$Author = property("DocAuthor", "$Item");
$NewName = "$Title" . "_" . "$Author";
rename b, "$NewName", p, "$Item";
}
This _should_ work but test it with a few copies of your files before.
I knew XY could do this because I use it for similar things.
And Highend you insisted on exiftool and did't trust me right?

Re: Batch rename PDF files using metadata?
Posted: 26 Mar 2012 19:39
by perseid
highend wrote:
Code: Select all
$SelectedItems = get("SelectedItemsPathNames", "|");
foreach($Item, $SelectedItems, "|") {
$Title = property("DocTitle", "$Item");
$Author = property("DocAuthor", "$Item");
$NewName = "$Title" . "_" . "$Author";
rename b, "$NewName", p, "$Item";
}
This _should_ work but test it with a few copies of your files before.
Wow!!! That worked! I tested the above script and the selected files were successfully renamed. Some PDF's were renamed without any info but it was not the script's fault, as I found out those PDF's had no associated metadata, so in those cases the only alternative is to manually open the files and copy the info.
I'd appreciate two minor changes to the above script if possible, instead of completely renaming the file, to just append the metadata info, that is, for example rename the file "trew98.pdf" as follows:"<Title>_<Author>_trew98.pdf". And also, for those PDF's that have no metadata, that the PDF remains unchanged (no renaming).
Thanks