Page 3 of 3

Re: Sync folders questions

Posted: 25 Jan 2024 07:12
by Schuller
1st RUN..
first test backup.jpg
first test backup.jpg (26.99 KiB) Viewed 1893 times
2nd RUN
second test sync.jpg
second test sync.jpg (22.86 KiB) Viewed 1893 times
So that worked well and will suffice for my daily sync button, thanks!

I had this written out for my bi-weekly button prior to you responding and now I'm not sure how to modify the script to include this and to include the same text file(s) which will show the last synced dates for each source/target line and perhaps modify the script even further to eliminate the need for that open throw away clone.

sync "C:\SCANSNAP", "D:\SCANSNAP(Target)(1of3) Synced on <date yyyy.mm.dd @ hh.nnam/pm>", 1, 0, 2, "kn";
sync "C:\SCANSNAP", "E:\SCANSNAP(Target)(2of3) Synced on <date yyyy.mm.dd @ hh.nnam/pm>", 1, 0, 2, "kn";
sync "C:\SCANSNAP", "W:\SCANSNAP(Target)(3of3) Synced on <date yyyy.mm.dd @ hh.nnam/pm>", 1, 0, 2, "kn";
sync "R:\OAKVILLE", "W:\OAKVILLE(Target)(1of2) Synced on <date yyyy.mm.dd @ hh.nnam/pm>", 1, 0, 2, "kn";
sync "R:\OAKVILLE", "X:\OAKVILLE(Target)(2of2) Synced on <date yyyy.mm.dd @ hh.nnam/pm>", 1, 0, 2, "kn";
sync "S:\TORONTO", "W:\TORONTO(Target)(1of2) Synced on <date yyyy.mm.dd @ hh.nnam/pm>", 1, 0, 2, "kn";
sync "S:\TORONTO", "X:\TORONTO(Target)(2of2) Synced on <date yyyy.mm.dd @ hh.nnam/pm>", 1, 0, 2, "kn";

Thanks again.

Re: Sync folders questions

Posted: 25 Jan 2024 08:36
by highend
If I'd need to do that my script would look like this

Code: Select all

    // {src}<:>{dst}<:>{filters}
    // Disable a specific job by prefixing it with: //
    $jobs = <<<>>>
C:\SCANSNAP<:>D:\SCANSNAP(Target)(1of3)<:>"-\Note20\Music\"|"-\Note20\Audiobooks\"
C:\SCANSNAP<:>E:\SCANSNAP(Target)(2of3)<:>
C:\SCANSNAP<:>W:\SCANSNAP(Target)(3of3)<:>
R:\OAKVILLE<:>W:\OAKVILLE(Target)(1of2)<:>
R:\OAKVILLE<:>X:\OAKVILLE(Target)(2of2)<:>
S:\TORONTO <:>W:\TORONTO(Target)(1of2)<:>
S:\TORONTO <:>X:\TORONTO(Target)(2of2)<:>
    >>>;
    // ========================================================================
    // == DO NOT CHANGE ANYTHING BELOW IF YOU DO NOT KNOW WHAT YOU ARE DOING ==
    // ========================================================================
    $jobs = regexreplace($jobs, "^//.*?(\r?\n|$)");

    setting "BackgroundFileOps", 0;
    $log = "";
    foreach($job, $jobs, <crlf>, "e") {
        $src     = gettoken($job, 1, "<:>", "t");
        $dst     = gettoken($job, 2, "<:>", "t");
        $dstPath = regexmatches($dst, "^.*\\");
        $filter  = gettoken($job, 3, "<:>", "t");
        $date    = <date yyyy.mm.dd @ hh.nnam/pm>;

        // Pre-checks
        if (exists($src) != 2)     { $log .= "Src: " . quote($src)     . " not found, skipping!" . <crlf>; continue; }
        if (exists($dstPath) != 2) { $log .= "Dst: " . quote($dstPath) . " not found, skipping!" . <crlf>; continue; }

        // Delete the last sync .txt file
        $txtPath = gettoken($dst, 1, "\");
        $txtPre  = gettoken($dst, 2, "\");
        $txts    = quicksearch($txtPre . "*.txt /n", $txtPath, "|");
        foreach($txt, $txts, "|", "e") { $result = runret(lax("cmd" /c DEL /F /Q "$txt"), "%TEMP%"); }

        // Sync
        if ($filter) {
            sync "$src", "$dst", 1, 0, 2, "kn", 7:=$filter;
        } else {
            sync "$src", "$dst", 1, 0, 2, "kn";
        }
        new("$txtPath\$txtPre Synced on $date.txt");
    }
    if ($log) { text $log; }

Re: Sync folders questions

Posted: 25 Jan 2024 12:42
by Schuller
Tried this and had to cancel the run. It seems I'm still unable to use XY while it is running and that I will need to run it in the throw away clone or fresh instance in order to use XY again?
Is there something further that I should configure?

Re: Sync folders questions

Posted: 25 Jan 2024 13:01
by highend
This has been said multiple times, you need a second instance if you don't want to block the main one during sync

Re: Sync folders questions

Posted: 25 Jan 2024 13:47
by Schuller
I must have misunderstood this..
meaning.jpg
meaning.jpg (146.58 KiB) Viewed 1855 times
I thought the script running in the second instance was going to be all part and parcel of hitting the script button in the main instance.

Anyway, going to run this script again with the open throw away clone now and see how that goes.

Re: Sync folders questions

Posted: 25 Jan 2024 15:55
by highend
You could run that script in a throw-away clone if necessary, again: via scripting

The script I posted should be put in a .xys file (create a normal .txt one, rename it, e.g. in: Sync.xys)
Put Sync.xys in your XY scripts folder

Append one more line to that file (at the end, indented by 4 spaces): exit "n"; and save it again.

Use a user defined button with this "script":

Code: Select all

run lax("<xy>" /new /readonly /win=normal,40,20,1200,800 /script="Sync.xys");
Edit the position parameters if necessary.

If you'd use "n" instead of "kn" in the two sync ... lines in the script file (to NOT keep the sync report open)
it would start a clone that loads and executes that script and automatically exits that second instance when done...

Re: Sync folders questions

Posted: 25 Jan 2024 15:59
by Schuller
Okay, will give this a try..
Thanks!

Re: Sync folders questions

Posted: 26 Jan 2024 13:27
by highend
So, does it work as expected now?

Re: Sync folders questions

Posted: 28 Sep 2024 03:41
by Schuller
I don't know yet. I had to put this on hold and keep using what I'm currently using. Once I know, I'll post back.

Re: Sync folders questions

Posted: 28 Sep 2024 03:55
by jupe
FYI, there is a background switch available for SC sync now.

Re: Sync folders questions

Posted: 28 Sep 2024 03:58
by Schuller
Thanks! will check it out later.