I can see some of the complications but in essence, whatever the source, we're looking to copy to a relative dir structure in the selected target.
Assume first that all files are from the same starting source, eg. C:\Data\Music
Search returns:
C:\Data\Music\Album1\Track01.mp3
C:\Data\Music\Album2\Track01.mp3
The user is likely to want to either recreate as:
\Data\Music\Album1\Track01.mp3
\Data\Music\Album2\Track01.mp3
or
\Album1\Track01.mp3
\Album2\Track01.mp3
ie. choose recreate structure from beginning (excluding drive or share name) or recreate structure from starting dir of search
You could go one step further and offer up each of the subdirs in the path as a starting point of structure recreation but I reckon 99% will want one of the two I have shown.
So then there's the complication of files added to the collection that don't have \Data\Music\ within their path ie. came from a different search source dir.
- If using option "recreate structure from beginning (excluding drive or share name)" its simple, just do exactly that.
So, a search of C:\Data\Music returning:
C:\Data\Music\Album1\Track01.mp3
C:\Data\Music\Album2\Track01.mp3
followed by a search of D:\Other Music returning:
D:\Other Music\AlbumX\Track01.mp3
D:\Other Music\AlbumY\Track01.mp3
would result in:
:: recreate structure from beginning (excluding drive or share name):
\Data\Music\Album1\Track01.mp3
\Data\Music\Album2\Track01.mp3
\Other Music\AlbumX\Track01.mp3
\Other Music\AlbumY\Track01.mp3
- If using option "recreate structure from starting dir of search", then there are several scenarios.
2a) If all files in the collection are from the same source dir, there's no issue.
2b) If files in the collection are made up of files from different source dirs/different searches then you need to choose from two paths. This could be user selectable:
2b-1) Choose which result set in the collection to use, probably based on first file in collection and look at the source dir it came from. Any file in the collection coming from that source can have its dir structure recreated in target dir. Any file in the collection that did NOT come from that same source would revert to being treated as "recreate structure from beginning (excluding drive or share name)".
would result in
:: recreate structure from starting dir of search:
\Album1\Track01.mp3
\Album2\Track01.mp3
\Other Music\AlbumX\Track01.mp3
\Other Music\AlbumY\Track01.mp3
2b-2) Recreate the structure from the starting dir of search for each file in the collection. You would need to store that info with the collection.
would result in
:: recreate structure from starting dir of search:
\Album1\Track01.mp3 (starting dir=C:\Data\Music, file found=C:\Data\Music\Album1\Track01.mp3)
\Album2\Track01.mp3 (starting dir=C:\Data\Music, file found=C:\Data\Music\Album1\Track01.mp3)
\AlbumX\Track01.mp3 (starting dir=D:\Other Music, file found=D:\Other Music\AlbumX\Track01.mp3)
\AlbumY\Track01.mp3 (starting dir=D:\Other Music, file found=D:\Other Music\AlbumY\Track01.mp3)
- If you were to offer more than choice 1 or 2, ie. offering up each of the subdirs in the source path as a starting point of structure recreation, this would get quite problematic where files in the collection came from different source dirs.
So, essentially it boils down to offering two/three options for target structure recreation, and applying some rules if necessary for handling files not adhering to the selected source dir structure.