I suppose a script, with the help of the
ListAttachments and
SetMetadata command line interface functions, could do the job.
Something like this:
var WshShell = new ActiveXObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var ForReading = 1,
ForWriting = 2,
ForAppending = 8;
var TristateUseDefault = -2,
TristateTrue = -1,
TristateFalse = 0;
function getPDFShellToolsPath() {
var oEnv = WshShell.Environment("System");
switch (oEnv("PROCESSOR_ARCHITECTURE").toLowerCase()) {
case "amd64":
return "\"%ProgramFiles(x86)%\\PDF-ShellTools\\PDFShellTools.exe\"";
default:
return "\"%ProgramFiles%\\PDF-ShellTools\\PDFShellTools.exe\"";
}
}
function AttachmentsListToMetadataField(filename) {
if (fso.GetExtensionName(filename) === 'pdf') {
var FilePath = fso.GetParentFolderName(filename);
var AttachmentsListFilename = FilePath + "\\Attachments.txt";
if (fso.FileExists(AttachmentsListFilename)) {
fso.DeleteFile(AttachmentsListFilename);
}
var ShellToolsPath = getPDFShellToolsPath();
WshShell.Run(ShellToolsPath + " ListAttachments \"OutFilename=" + AttachmentsListFilename + "\" \"" + filename + "\"", 0, true);
if (fso.FileExists(AttachmentsListFilename)) {
var ts = fso.OpenTextFile(AttachmentsListFilename, ForReading, false, TristateFalse);
var Attachments = new Array;
while (!ts.AtEndOfStream) {
Attachments.push(ts.ReadLine());
}
ts.Close();
fso.DeleteFile(AttachmentsListFilename);
WshShell.Run(ShellToolsPath + " SetMetadata -UTF8Encoded \"Metadata='Attachments=" + Attachments.join(';') + "'\" \"" + filename + "\"", 0, true); }
}
}
var objArgs = WScript.Arguments;
for (i=0; i<objArgs.length; i++){
AttachmentsListToMetadataField(objArgs(i));
}
Save this code to an
AttachmentsToMetadata.js file and put it in the SendTo folder (type
shell:sendto in the Windows Explorer address bar to easily locate, and open, this folder).
Now you just need to select the PDF files, right click them, and choose the Shell context menu "
send to>AttachmentsToMetadata.js" item, to get these PDF files attachments names saved to a PDF custom metadata field, named
Attachments.