Start a new topic
Answered

New Picture path after migration to new machine - remap?

Maybe I just missed it but is there a chance to remap all picture paths? Simple explanation: On my old machine all pictures were stored in E:\abcd\pics Now on my new machine drive E is gone it is just D:\pics Of course setting the picture paths in options is possible but that seems not to effect all (existing) pictures. Any idea except creating a drive E? ;-)

Best Answer

You could do this with a script. Something like this should do it (please make sure you have a backup before executing this. I did try this before but it might not work equally well for others...)


using System;

using NeonScripting;

using System.Collections;

using System.Collections.Generic;

using System.IO;

using System.Text;

using System.Text.RegularExpressions;

using System.Linq;


public class Script

{

    public bool Run(INeonScriptHost host)

    {

        var oldPictureFolder = host.RemoteCalls.InputDialog("Please type in the old picture path.");

        var newPictureFolder = host.RemoteCalls.InputDialog("Please type in the new picture path.");

        

        if(string.IsNullOrEmpty(oldPictureFolder) || string.IsNullOrEmpty(newPictureFolder))

        {

            return false;

        }

        

        var albums = host.Database.Albums.ToList();

        var idx = 1;

        foreach (var album in albums)

        {

            host.UpdateProgress($"Updating album picture path for album {idx} of {albums.Count()}");


            if(album.AlbumPicturePath.StartsWith(oldPictureFolder)) 

            {

                var newAlbumPicturePath = album.AlbumPicturePath.Replace(oldPictureFolder, newPictureFolder);

                host.Database.UpdateAlbumPicture(album, newAlbumPicturePath);

            }

            idx++;

        }


        return true;

    }

}



Glad it worked! Happy to help :-)

Login or Signup to post a comment