CSV export - photo path


I apologize in advance should this issue have already been discussed, yet I didn’t seem to find any mention of this.

I am exporting a CSV file of my project with the CSV plugin. Everything is fine, I get the fields I need. I also made it include the photos into the table it eventually produces. However, for every photo belonging to one object, it shows me its whole file path.
Like this “C:\Users\XY…\Project\Image01.jpg;C:\Users\XY…\Project\Image02.jpg” etc

With an object, comprising 10 photos or more, this quickly turns into a mess.

My question was: Is there a possiblity to just have the CSV file show me the file names of the photos? So instead of several file paths, it just lists me “Image01.jpg, Image02.jpg. …” Because I would need to have the photos included into a list for a specific task, but with the whole file path, it becomes far too confusing.

I couldn’t figure out how to do that.
I hope my problem description is understandable. So, is there a solution to this issue?


There’s currently no such option in the plugin, no. However, it should be relatively easy to achieve this by modifying the plugin and I’m happy to walk you through it.

In Tropy, select Help -> Show Plugins Folder from the menu and then open the CSV plugin where you should see an index.js file. We should be able to get your desired results by adding two simple modifications to that file:

First, change line 5 by adding the basename import like this:

const { basename, join } = require('path')

Next, change line 33 by wrapping the path in a call to basename(...) like this:

.map(x => basename(value(x[`${TROPY}#path`])))

Be careful not to miss the closing parenthesis. With these changes, I think you should get the results you’re looking for by reloading or restarting Tropy and exporting your items. I haven’t tested this, so apologies in advance if I’ve missed anything – just let me know if it doesn’t work and I’ll take another look!

On line 31 you could also change the separator to use ', ' instead of ';' if you want the filenames to be separated by commas instead.

@inukshuk thanks for your answer! This was exactly what I needed!
Sorry for my late reply, but I have been busy so I couldn’t sit down to get it done immediatly!
:+1: :+1: :+1:

1 Like