Batch rename PDF files using metadata?
Batch rename PDF files using metadata?
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?
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.
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Batch rename PDF files using metadata?
Hi an Welcome!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
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?
@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).
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).
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Batch rename PDF files using metadata?
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.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).
Re: Batch rename PDF files using metadata?
Script (full output):Really? On my PDFs i can see atleast title, author and year.
Wheras exiftool shows (ripped 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
Title : AutoIt leicht gemacht
Author : Johannes Mitlmeier
Create Date : 2010:09:29 22:29:21+02:00
etc.
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Batch rename PDF files using metadata?
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.highend wrote:Script (full output):Really? On my PDFs i can see atleast title, author and year.Wheras exiftool shows (ripped 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:58Title : AutoIt leicht gemacht
Author : Johannes Mitlmeier
Create Date : 2010:09:29 22:29:21+02:00
etc.
Re: Batch rename PDF files using metadata?
NopeThere are some duplicate items but you should see author, title and date atleast.

Output:
Win 7 x64 SP1 Ultimate, German.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
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Batch rename PDF files using metadata?
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.highend wrote:NopeThere are some duplicate items but you should see author, title and date atleast.![]()
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?
Sure, I'll always try to solve that with in build functions as well (if applicable). The problem is: the techniqueWas just hoping that one need not have to go through 3rd party solutions when XY offers one.
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

One of my scripts helped you out? Please donate via Paypal
Re: Batch rename PDF files using metadata?
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
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
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
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
This is what I see: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.
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
This is what I see: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.
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
-
- XY Blog Master
- Posts: 5826
- Joined: 02 Jan 2006 19:34
- Location: So. Chatham MA/Clearwater FL
- Contact:
Re: Batch rename PDF files using metadata?
Hi and welcome to the XY forums!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).
Knowing what OS you're on helps as answer can vary based on that.
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.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
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.
Re: Batch rename PDF files using metadata?
Really? *g*I'm sure they will provide the rest of the answer
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";
}
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Batch rename PDF files using metadata?
I knew XY could do this because I use it for similar things.highend wrote:Really? *g*I'm sure they will provide the rest of the answer
This _should_ work but test it with a few copies of your files before.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"; }
And Highend you insisted on exiftool and did't trust me right?

Re: Batch rename PDF files using metadata?
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.highend wrote:This _should_ work but test it with a few copies of your files before.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"; }
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