Page 1 of 1

syn () function ant tag

Posted: 24 May 2024 18:56
by zzjean
I'm new to the art of scripting and am trying to learn with help file and forum posts. I manage to resolve a number of problems, but get nowhere with the following:

I want to synchronize directories between different external hard drives. Concretely, I have a Photo directory on G:\ with several levels of subdirectories. I have exactly the same structure on H:\ and Q:\.
G:\ serves as a reference i.e. I make the modifications and synchronize on H:\ and Q:\. I use the sync() function

There are just under 4TB of photos.
I cannot copy the tags from G:\ to the other disks, unless I overwrite everything, which is impossible, even by proceeding under level 2 sub-directories by level 2 sub-directories for example.

Is there any solution to this problem ? I've been searching for a while and can't seem to find an answer, although I think the question has probably been asked before.
The ideal would obviously be to only copy the new tags

I hope my message is, if not very clear, at least understandable.

Thank you for your help

Google translation

Re: syn () function ant tag

Posted: 24 May 2024 19:56
by highend
Then write a script that copies only the tags?

Code: Select all

    $srcPath  = "G:\photos";
    $dstPaths = "H:\photos|Q:\photos";
    $srcDrive = gpc($srcPath, "drive");

    $files = quicksearch("/t", $srcPath);
    end (!$files), "No tagged file(s) found, aborted!";

    foreach($file, $files, <crlf>, "e") {
        $srcTags  = tagitems("tags", , $file);
        $dstPath1 = gettoken($dstPaths, 1, "|");
        $dstPath2 = gettoken($dstPaths, 2, "|");

        $newFile = replace($file, $srcDrive . ":", gpc($dstPath1, "drive") . ":");
        if (exists($newFile) == 1) {
            $dstTags = tagitems("tags", , $newFile);
            if ($srcTags != $dstTags) { tagitems("tags", $srcTags, $newFile); }
        }
        $newFile = replace($file, $srcDrive . ":", gpc($dstPath2, "drive") . ":");
        if (exists($newFile) == 1) {
            $dstTags = tagitems("tags", , $newFile);
            if ($srcTags != $dstTags) { tagitems("tags", $srcTags, $newFile); }
        }
    }
    e "Done!";

Re: syn () function ant tag

Posted: 24 May 2024 20:18
by zzjean
Thank you - I'm going to try this and see how it's done to learn a little more :D

Re: sync () function and tag

Posted: 25 May 2024 03:59
by jupe
If your main aim is backing up all the the tags/lbl/cmt/ex, I'd suggest just exporting the tags into the root folder first before the sync operation, then all the tags are in 1 file and backed up in the same sync command. Check out SC tagexport.

Also FYI if you use the script posted, be aware that in its current state, it is copying "tags" only.