Last active
December 15, 2015 04:08
-
-
Save caschwartz/5198882 to your computer and use it in GitHub Desktop.
XQuery - Query filesystem to load PDF files and modify PDF filenames
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| xquery version "1.0-ml"; | |
| (: 3/27/13 Query the filesystem to add finalized PDFs to a MarkLogic database using the <dc:identfier> value for the filenames :) | |
| declare namespace tei = "http://www.tei-c.org/ns/1.0"; | |
| declare namespace localtei = "http://my.local.tei.customized.schema/tei"; | |
| declare namespace dc = "http://purl.org/dc/elements/1.1/"; | |
| for $teiDoc in fn:collection() | |
| let $newID := $teiDoc/tei:TEI/tei:teiHeader/localtei:metadata/dc:identifier | |
| let $sourceID := $teiDoc/tei:TEI/tei:teiHeader/localtei:metadata/dc:source | |
| let $filenames := xdmp:filesystem-directory("c:\my-pdf-files")/dir:entry/dir:filename | |
| for $filename in $filenames | |
| let $fileLocation := $pdfFile/following-sibling::dir:pathname | |
| where $sourceID = $filename | |
| return xdmp:document-insert(fn:concat("/PDF/youth/", fn:data($newID), ".pdf"), xdmp:external-binary($fileLocation)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment