Sync folders questions

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Schuller
Posts: 184
Joined: 02 May 2023 21:08

Re: Sync folders questions

Post by Schuller »

1st RUN..
first test backup.jpg
first test backup.jpg (26.99 KiB) Viewed 1894 times
2nd RUN
second test sync.jpg
second test sync.jpg (22.86 KiB) Viewed 1894 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.

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Sync folders questions

Post 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; }
One of my scripts helped you out? Please donate via Paypal

Schuller
Posts: 184
Joined: 02 May 2023 21:08

Re: Sync folders questions

Post 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?

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Sync folders questions

Post 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
One of my scripts helped you out? Please donate via Paypal

Schuller
Posts: 184
Joined: 02 May 2023 21:08

Re: Sync folders questions

Post by Schuller »

I must have misunderstood this..
meaning.jpg
meaning.jpg (146.58 KiB) Viewed 1856 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.

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Sync folders questions

Post 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...
One of my scripts helped you out? Please donate via Paypal

Schuller
Posts: 184
Joined: 02 May 2023 21:08

Re: Sync folders questions

Post by Schuller »

Okay, will give this a try..
Thanks!

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Sync folders questions

Post by highend »

So, does it work as expected now?
One of my scripts helped you out? Please donate via Paypal

Schuller
Posts: 184
Joined: 02 May 2023 21:08

Re: Sync folders questions

Post 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.

jupe
Posts: 3292
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Sync folders questions

Post by jupe »

FYI, there is a background switch available for SC sync now.

Schuller
Posts: 184
Joined: 02 May 2023 21:08

Re: Sync folders questions

Post by Schuller »

Thanks! will check it out later.

Post Reply