Convert mapped drive to UNC

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Convert mapped drive to UNC

Re: Convert mapped drive to UNC

by hostonmark » Wed May 05, 2010 8:38 am

This is very simple.A call to WNetGetConnection API returns the UNC name for any drive letter, most drives typically are not mapped.

I've put together a loop that calls a DriveLetterToUNC function on each letter of the alphabet from C to Z,prepares an adequate buffer by creating a string that's MAX_PATH characters long, then passes this string with the buffer length and drive letter to WNetGetConnection.

Your code extracts the UNC name from the buffer by scanning for the first Null character and trimming just before it.

Re: Convert mapped drive to UNC

by bkenobi69 » Fri Apr 09, 2010 9:41 am

Just to close my question...

I found that when I updated the mapped path to a UNC path using the SQL-Viewer script + the instructions mentioned, the artwork is automatically updated to the UNC path. Thus, there is no extra step(s) required to get artwork to work.

Re: Convert mapped drive to UNC

by davidbspalding » Fri Apr 09, 2010 8:32 am

(sidebar)

Ahhh.... I thought play counts and ratings were stored in MP3 files. Using the File Monitor feature in Options somehow bypasses resetting play counts, I presume.

Re: Convert mapped drive to UNC

by bkenobi69 » Thu Apr 08, 2010 2:03 pm

What would be the field names needed to update the artwork path which are linked to the mapped drive?

Re: Convert mapped drive to UNC

by nohitter151 » Wed Apr 07, 2010 9:42 pm

davidbspalding wrote:
I might've missed something as to why you need to edit the database directly. Letting MM manage the tables seems a safer policy (unless you're experienced at SQL queries).
Editing the database directly is better in the case where you have previously added tracks to a MM library and don't want to lose library-specific data (playcounts, playlists, etc.) which would be lost by rescanning the library, removing dead links, etc.

Re: Convert mapped drive to UNC

by davidbspalding » Sun Jan 10, 2010 6:28 pm

Edit the database? :o This seems like a lot of trouble. As per this FAQ on networked drive MM database, I simply changed all entries in mm.ini from e.g. s:\mp3\src\ to \\192.168.1.11\share1\mp3\src\, restarted MM, used Add/Rescan to reinforce the mappings for all tracks (unnecessary from what I could see), then went about my business. I'm using MM 3.2 btw.

I might've missed something as to why you need to edit the database directly. Letting MM manage the tables seems a safer policy (unless you're experienced at SQL queries).

Re: Convert mapped drive to UNC

by danhackley » Fri Dec 18, 2009 5:38 am

Thanks, I've got it sussed now!

Re: Convert mapped drive to UNC

by nohitter151 » Tue Dec 15, 2009 2:18 pm

danhackley wrote: What does "add a duplicate test track from the new (UNC) location" mean?
It means to scan a single track from the new location.

Re: Convert mapped drive to UNC

by danhackley » Tue Dec 15, 2009 12:18 pm

This looks like what I need, but I don't understand some of the instructions from John.

John states:

"To find out the new location IDMedia (together with the current IDMedia locator), add a duplicate test track from the new (UNC) location. and run:

Code: Select all
select * from Songs where songtitle = "example song title""

What does "add a duplicate test track from the new (UNC) location" mean?

Would be grateful if someone could explain this in less tehnical language.
Thanks!

Re: Convert mapped drive to UNC

by Nova5 » Thu Oct 15, 2009 6:13 pm

Moving things about on a server is a great benefit of a UNC share name. The client won't care if the server moved it from D:\Music to t:\Datashare\Auditory\Music

It only ever sees \\Server\Music.

never knows it moved, and never gives the monkey heartburn. If you have a mapped drive the only problem is sometimes the mapped drives in windows vanish for no apparent reason. Giving the poor monkey an anyerism.

Re: Convert mapped drive to UNC

by ZPrime » Fri Oct 02, 2009 10:49 pm

I really hate to bump this thread, but I had some info that will help others in my situation.

For a UNC path, IDMedia is always 1. Hence, moving stuff around between various UNC paths is as simple as running the update statement above with the "replace()" function in there.

I seem to reorganize my stuff every year or so and I end up moving shares around on my server (a WHS) and I always have to dig this thread up because I forget the syntax for the replace command. :lol:

Re: Convert mapped drive to UNC

by beg » Sun Jul 12, 2009 9:27 am

Hi,

I tried to use this instruction in order to use my music collection and MM database on my external HDD connected to a laptop as a copy of my music and database from home network, but got the same problem like moot.point. I can list all the songs by current IDMedia, but when trying to replace the songpath-part it does nothing. But I also tried the ":/" like moot.point suggest, which did not make a difference in my case.. :(

any ideas why this is not working in my situation?

Re: Convert mapped drive to UNC

by moot.point » Tue Jan 20, 2009 1:04 pm

johnieutah wrote: 2. Now we know the IDMedia, run the path change query:

Code: Select all

update Songs set SongPath = replace(SongPath, "<current location>", "<new location>") WHERE IDMedia = "<current IDMedia>"
e.g.

Code: Select all

update Songs set SongPath = replace(SongPath, "M:\", "\\SERVER\Music\") WHERE IDMedia = "63"
3. Update the IDMedia to the new location for all songs:

Code: Select all

update Songs set IDMedia = "<new IDMedia>" WHERE IDMedia = "<old IDMedia>"
That's it, worked great for me, and obviously useful no matter which locations are changing, whether it's a mapped drive to UNC or vice-versa etc...

Regards, Matt.
Hi Matt,

thanks for the detailed instructions! I had only one small issue with the "replace" Query: In the form above it did not alter the paths because MM did not save drive letters in my DB. This may be because the relevant drive was an external USB drive, but either way, MM usually works with the drive IDs not with the letters.

Anyway, it worked fine when I used the above query with <current location> in the form ":\" rather than "M:\" (assuming that M was the drive letter previously assigned).

SQLView is a brilliant tool!

Cheers,
Malte

Re: Convert mapped drive to UNC

by johnieutah » Mon Oct 27, 2008 1:47 pm

nohitter151 wrote:I believe you can do it with this script: http://www.mediamonkey.com/forum/viewto ... =2&t=24841 and that there are instructions on how to do it somewhere in the thread.
Cheers for that - worked a treat!

Here's the way to do it for anyone else interested. Go to the thread linked to above, download and install SQL Viewer. Back-up your MM DB first before running any of these queries as you don't want to trash your DB and having nothing to go back to!

1. Find out the IDMedia of both the current and new locations. To find out the new location IDMedia (together with the current IDMedia locator), add a duplicate test track from the new (UNC) location. and run:

Code: Select all

 select * from Songs where songtitle = "example song title"
2. Now we know the IDMedia, run the path change query:

Code: Select all

update Songs set SongPath = replace(SongPath, "<current location>", "<new location>") WHERE IDMedia = "<current IDMedia>"
e.g.

Code: Select all

update Songs set SongPath = replace(SongPath, "M:\", "\\SERVER\Music\") WHERE IDMedia = "63"
3. Update the IDMedia to the new location for all songs:

Code: Select all

update Songs set IDMedia = "<new IDMedia>" WHERE IDMedia = "<old IDMedia>"
That's it, worked great for me, and obviously useful no matter which locations are changing, whether it's a mapped drive to UNC or vice-versa etc...

Regards, Matt.

Re: Convert mapped drive to UNC

by nohitter151 » Sun Oct 26, 2008 1:03 pm

I believe you can do it with this script: http://www.mediamonkey.com/forum/viewto ... =2&t=24841 and that there are instructions on how to do it somewhere in the thread.

Top