2

IEEE Xplore から非常に多数 (数千) の PDF ファイルをダウンロードしています。

ファイル名には、ファイルの記事番号のみが含まれます。例えば

6215021.pdf

今、訪れるなら

http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=6215021

この記事に関して入手可能なすべての情報を見つけることができます。

サイトのソース コードを確認すると、以下のセクションが見つかります。

        <meta name="citation_title" content="Decomposition-Based Distributed Control for Continuous-Time Multi-Agent Systems">
        <meta name="citation_date" content="Jan. 2013">
        <meta name="citation_volume" content="58">
        <meta name="citation_issue" content="1">
        <meta name="citation_firstpage" content="258">
        <meta name="citation_lastpage" content="264">
        <meta name="citation_doi" content="10.1109/TAC.2012.2204153">
        <meta name="citation_abstract_html_url" content="http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=6215021' escapeXml='false'/>">
        <meta name="citation_pdf_url" content="http://ieeexplore.ieee.org/iel5/9/6384835/06215021.pdf?arnumber=6215021">
        <meta name="citation_issn" content="0018-9286">
        <meta name="citation_isbn" content="">
        <meta name="citation_language" content="English">
        <meta name="citation_keywords" content="
        Distributed control;
        Output feedback;
        Satellites;
        Stability criteria;
        Standards;
        State feedback;
        Upper bound;
        Distributed control;
        linear matrix inequality (LMI);
        multi-agent systems;
        robust control;">

私が持っているファイルの名前を「firstpage - citation_title.pdf」に変更したいと思います

私のプログラミング スキルは限られているため (一部の C のみ、解析についての手がかりはありません)、あなたの助けを期待しています。

よろしくお願いします!

4

2 に答える 2

1

iTextSharpライブラリを使用して、次の C# コードをコンパイルできます。件名やタイトルなど、PDF ファイルのメタデータに基づいて、ディレクトリ内のすべての PDF ファイルの名前を変更します。

using System.IO;
using iTextSharp.text.pdf;

namespace BatchRename
{
    class Program
    {
        private static string getTitle(PdfReader reader)
        {
            string title;
            reader.Info.TryGetValue("Title", out title); // Reading PDF file's meta data
            return string.IsNullOrWhiteSpace(title) ? string.Empty : title.Trim();
        }

        private static string getSubject(PdfReader reader)
        {
            string subject;
            reader.Info.TryGetValue("Subject", out subject); // Reading PDF file's meta data
            return string.IsNullOrWhiteSpace(subject) ? string.Empty : subject.Trim();
        }

        static void Main(string[] args)
        {
            var dir = @"D:\Prog\1390\iTextSharpTests\BatchRename\bin\Release";
            if (!dir.EndsWith(@"\"))
                dir = dir + @"\";

            foreach (var file in Directory.GetFiles(dir, "*.pdf"))
            {
                var reader = new PdfReader(file);
                var title = getTitle(reader);
                var subject = getSubject(reader);
                reader.Close();

                string newFile = string.Empty;
                if (!string.IsNullOrWhiteSpace(title))
                {
                    newFile = dir + title + ".pdf";
                }
                else if (!string.IsNullOrWhiteSpace(subject))
                {
                    newFile = dir + subject + ".pdf";
                }

                if (!string.IsNullOrWhiteSpace(newFile))
                    File.Move(file, newFile);
            }
        }
    }
}
于 2013-01-11T20:44:09.373 に答える