Match strings on two lists that aren't identical?

Hey there

My overall goal is to load GPS data from photos and import it onto a Civil 3D file. Like this:

The photos I want to use will live on Sharepoint.
Because I can’t import straight from Sharepoint (403) I’ve synced the folder to my onedrive so i can access it and extract the data, however these hyperlinks will lead to my local folder. I’m trying to use a work around where I download the excel spread sheet of files from the sharepoint (saved as a .csv), find the hyperlinks and match those up with the local files.

With this technique the two lists created are matching in size, but as expected from two ways of sorting, very mixed up. (Because of subfolders, this technique works for a single folder)


Is there a way to match up lists that have different directory paths at the start?
A way to match up similar strings in both lists, even if the whole string isn’t the same?

Or any easier way you could think of doing this I’d love to hear :slight_smile:

New to this so hope the question is okay
Insert Photo Map Location Example.dyn (67.7 KB)

Thanks!

1 Like

Hi @Visska,

Is this what you’re looking for? Just swap some of the inputs to determine which list to match.

SortPathsByFileName.dyn (19.4 KB)

SortPaths

4 Likes

Hi @mzjensen

Thanks for this. I think this would work for my example, but I’d love to be able to automate it more so that I wouldn’t have to type what to search for or replace with. I should’ve mention that at the start, sorry.

I’m hoping to be able to use this for many different file directories and want it to be as smooth as possible. So I’m thinking a way to just reorder the files to ‘match’ would be best? If thats possible

You have to select the directory path earlier in the script, right? So you can just use that and there’s no need to type it in every time.

The String.Replace node is really acting more like a String.Remove node to isolate the file name. It’s just easier to replace with an empty string than it is to get the specific character indices to remove.

That’s what the example above does. I was just showing how it works on two generic lists of strings because I don’t have access to the same directories and files that you do. But it will work the same way with the lists of paths that you show in your screenshots.

The concept is the same: isolate the file names from the paths (since that is the only thing that is common between the two lists), get the indices, and then sort the original lists according to those indices.

1 Like

Hey @mzjensen,

Thanks for explaining further. I didn’t have a chance to test it so I was a bit confused about how it would work.

That all sounds great :smile:

Thanks again!