|
* External Email - Caution * |
The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.
Yeah, today I learned that there’s not a way to do what you’re trying to do. I thought there was! But unfortunately I was wrong.
Charlie’s correct: you could fairly easily write a script that would find and rename all of the files under your various resource folders. And rather than refreshing each of the resource catalogs, you could use a tool like sed or awk to change the names in the catalog files as well. Each catalog file contains zero to n entries, either <cat:entry> or <cat:dcmEntry>, each of which references an individual file. In its current architecture, XNAT has no references to anything lower than the resource catalog file, so you can rename the files there and modify references in the catalog at the same time. Suppose you have a catalog file like this (I cut a lot of stuff out of here for readability, so make sure you look at the catalog files you’ll be working with!):
<?xml version="1.0" encoding="UTF-8"?>
<cat:Catalog ID="FOO" xmlns:cat="http://nrg.wustl.edu/catalog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<cat:entries>
<cat:entry ID="item1.pdf" URI="item1.pdf" cachePath="item1.pdf" content="PDF" digest="cc8ac14fd94ba5979f27346949df6dbc" format="PDF" name="item1.pdf"/>
<cat:entry ID="item2.txt" URI="item2.txt" cachePath="item2.txt" content="TEXT" digest="ded4c18106345a8b39de6f12943eb4aa" format="TXT" name="item2.txt"/>
</cat:entries>
</cat:Catalog>
If you wanted to do something like change the naming from itemN.ext to fileN.ext, you could use a command like this:
$ sed -E --in-place=".bak" 's/"item([0-9]+)\.([a-z0-9]+)"/"file\1.\2"/g' FOO_catalog.xml
This holds even if you’re working with resources in a folder structure. Since XNAT doesn’t know anything about where those files are located relative to the resource, you just need to fix up the various paths as well. The paths below the resource folder are reflected in the ID, URI, and cachePath attributes of the <cat:entry> and <cat:dcmEntry> elements, but not in the name attribute.
<cat:entry ID="subfolder/qa-notes.docx" URI="subfolder/qa-notes.docx" cachePath="subfolder/qa-notes.docx" name="qa-notes.docx">
Once you’ve renamed the files and changed the references in the catalog, you can just start using the system with your new organization.
--
Rick Herrick
Sr. Programmer/Analyst
Neuroinformatics Research Group
Washington University School of Medicine
Phone: +1 (314) 273-1645
To view this discussion on the web visit https://groups.google.com/d/msgid/xnat_discussion/CH2PR02MB67102789C595803508BF2477FE7D9%40CH2PR02MB6710.namprd02.prod.outlook.com.
Excellent, I’m glad that’s working for you. I did add an issue to our Jira for a new feature to allow renaming and moving files within a resource folder, but no timeline on when that might get done.
--
Rick Herrick
Sr. Programmer/Analyst
Neuroinformatics Research Group
Washington University School of Medicine
Phone: +1 (314) 273-1645
To view this discussion on the web visit https://groups.google.com/d/msgid/xnat_discussion/b6f503b6-c5b4-4b51-be6d-7e99983de871n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xnat_discussion/23e24e1a-0921-4b2a-806b-51238d7dcd3dn%40googlegroups.com.