Automated Folder Compare - host to 7 other folders

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gmesheau
    Visitor
    • Nov 2008
    • 5

    Automated Folder Compare - host to 7 other folders

    Let me begin to say Im new to coding, and using this program in general.

    I've searched, and sifted through the scripting posts, and found some good help, but nothing to specific to my problem.

    Basically I have a host folder, and 7 other computers with the matching folder.

    When I update the host folder I need BC3 to update the 7 other computers to match the host, automatically.

    Is this achievable?

    Host Folder Path: C:\Program Files\Bohemia Interactive\VBS2 VTK\vbs2\addons

    to match:
    \\Pc1\vbs2\addons
    \\Pc2\vbs2\addons
    \\Pc3\vbs2\addons
    \\Pc4\vbs2\addons
    \\Pc5\vbs2\addons
    \\Pc6\vbs2\addons
    \\Pc7\vbs2\addons
  • Aaron
    Team Scooter
    • Oct 2007
    • 15997

    #2
    Hello,

    This would not be automatic in terms of detectable, but could be a scheduled/routine task.

    You would write a script that would perform a single sync.
    load %1 %2
    sync update (or mirror):lt->rt

    More detailed examples can be found in the Help file -> Using Beyond Compare -> Command Line and Scripting. If you would like further script help here, post what you have, and let us know what actions you'd like to perform as if you were using the GUI.

    The script would then be in a bat file that would call it 7 times, on each of the folders.
    bcompare.exe @scriptFile.txt "C:\Program Files\Bohemia Interactive\VBS2 VTK\vbs2\addons" "\\Pc1\vbs2\addons"
    bcompare.exe @scriptFile.txt "C:\Program Files\Bohemia Interactive\VBS2 VTK\vbs2\addons" "\\Pc2\vbs2\addons"
    etc.
    where c:\program files is in the first position after the scriptFile.txt, so it would be %1 in script, and \\Pc1 or \\Pc2 would be %2.

    This bat file would then be called as a Windows Scheduled Task at whatever interval you would like, syncing all 7 folders at that time. It could then be easily expanded by adding more folders to your bat file, or by altering the single script file.

    **Until you are more certain of how script will work, I recommend working only with Test files, or backed up data.**

    Let us know if you have any questions.
    Aaron P Scooter Software

    Comment

    • gmesheau
      Visitor
      • Nov 2008
      • 5

      #3
      Thanks for the response.
      I've been playing with the Windows Scheduled Task, beeing new at scripting, I just wanted ask some quick fundamental questions.
      Where should my script files be held, and can the bat file be created the same way I created the first script file, with the ext. .txt?

      Comment

      • gmesheau
        Visitor
        • Nov 2008
        • 5

        #4
        So, this is what I have thus far.

        I've created a file (scriptFile.txt) which contains the following:

        load %1 %2
        sync update (or mirror):lt->rt

        Also I've created a bat file (Batfile.bat) which contains:

        bcompare.exe @scriptFile.txt "C:\Program Files\Bohemia Interactive\VBS2 VTK\vbs2\addons" "\\Pc1\vbs2\addons"
        bcompare.exe @scriptFile.txt "C:\Program Files\Bohemia Interactive\VBS2 VTK\vbs2\addons" "\\Pc2\vbs2\addons"
        bcompare.exe @scriptFile.txt "C:\Program Files\Bohemia Interactive\VBS2 VTK\vbs2\addons" "\\Pc3\vbs2\addons"
        bcompare.exe @scriptFile.txt "C:\Program Files\Bohemia Interactive\VBS2 VTK\vbs2\addons" "\\Pc4\vbs2\addons"
        bcompare.exe @scriptFile.txt "C:\Program Files\Bohemia Interactive\VBS2 VTK\vbs2\addons" "\\Pc5\vbs2\addons"
        bcompare.exe @scriptFile.txt "C:\Program Files\Bohemia Interactive\VBS2 VTK\vbs2\addons" "\\Pc6\vbs2\addons"
        bcompare.exe @scriptFile.txt "C:\Program Files\Bohemia Interactive\VBS2 VTK\vbs2\addons" "\\Pc7\vbs2\addons"

        I've schedualed an automatic task of running BatFile.bat every minute betwen 8-5 week days.
        Doesn't seem to be doing the update for me, as the status of the schedualler advises it "Could Not Start".
        One thing I did notice is the extensions in the folder aren't showing up (.bat) on the end of my BatFile. Windows is new to me as Im usually on a mac, so don't laugh if thats a pretty elemantary question. hehe
        Thanks.
        g

        Comment

        • gmesheau
          Visitor
          • Nov 2008
          • 5

          #5
          So, as of now:

          Scheduler is running, and giving me and exit code of 1, which tells me that it ran the batch file(turned extensions on in folder options)

          Although its not giving me any results.
          note: the "(or mirror)" was deleted from the script file
          Last edited by gmesheau; 01-Dec-2008, 11:18 AM. Reason: typo

          Comment

          • gmesheau
            Visitor
            • Nov 2008
            • 5

            #6
            alright, I know I may be posting quite a bit, but i fugred the more info I supply, the easier it will be for you guys to determine what my issue is.

            The code all seems to be fine, as I can manually click on the batch file to have it open command prompt as well as a status window of my sync. repeating for the 7 different computers.

            When the Sceduler attemps the task, it only opens the command prompt for a split second then closes without anything happening.

            Any thoughts?

            Comment

            • chrroe
              Pooh-Bah
              • Oct 2007
              • 588

              #7
              Have you read this Knowledgebase article?

              http://www.scootersoftware.com/suppo...b_schedule.php

              Furthermore can you please post a screenshot of your scheduled task dialog entries? I think that would be helpfull.


              Bye
              Christoph

              Comment

              • Aaron
                Team Scooter
                • Oct 2007
                • 15997

                #8
                Hello,

                the "or mirror" was pseudo code, you would want to use one command or the other.
                sync update:lt->rt
                sync mirror:lt->rt

                Exact syntax and further examples are available in the Help file under Using Beyond Compare -> Command Line and Scripting section.

                I *highly* recommend using script on Test or Backed up data. Mirror is a destructive command, and will delete data based on a series of logical rules (in order to make rt the same as lt). You wouldn't want to delete any data as you learn to use the application.

                I also recommend using the application and sync process via the interface first. The script itself mirrors commands taking in the application. So for example, launching the application, loading 2 folders, then going to the Actions menu -> Synchronization: Update lt->rt is the same as loading your script.
                If, however, as you use the application you determine you want to change your criteria in some way, that command needs to be set as the default or put into script. Once you are successfully syncing (with test/backed up data), then it is good to script out the steps.

                The bat file itself looks ok. The reason you may not be seeing the extensions is that they are normally hidden by default for "known filetypes."

                Side Note:
                You can change this windows setting by opening a Windows Explorer or My Computer and going to the Tools menu -> Folder Options (or by going to the Control Panel -> Folder Options. both lead to the same place). Then the View tab, then uncheck Hide extensions for known file types.
                Be careful, however, because now if you go to rename a file, you MUST retype it's extension. Otherwise, you will change its filetype to none, and it will not open correctly.
                Aaron P Scooter Software

                Comment

                • Aaron
                  Team Scooter
                  • Oct 2007
                  • 15997

                  #9
                  Also, you can start out simpiler. Instead of calling the bat file right away, you can simply call one line of it from the command line.

                  Test your script with:
                  bcompare.exe @script location1 location2

                  Then, once it is working, then move on to getting it to work with the bat file and the multiple calls. The bat file can then be called from the command line just by typing it in.
                  c:\folder\batfile

                  Then, once the bat file seems to be working, move on to Windows Scheduled Tasks. I would recommend a much higher count than 1 minute, as you probably do not want to have the task start again while the first task is still running. There are some options to help prevent this, but the easiest way is to simply time roughly how long it takes to perform once, and give it several minutes to half and hour of buffer.
                  Aaron P Scooter Software

                  Comment

                  • gmesheau
                    Visitor
                    • Nov 2008
                    • 5

                    #10
                    i've gotten all the bugs worked out. thanks for the help

                    everything is working fine, and updates are accuring across the network.

                    couple questions I had,

                    Is there a way around the task scheduler? one thing i would like to have is the batch file only run when someone copy's something new into the "addons" folder on the host.

                    also, is there a way to run this in the background? rather then having it pop up every time it runs.

                    thanks for the help!!
                    g

                    Comment

                    • Aaron
                      Team Scooter
                      • Oct 2007
                      • 15997

                      #11
                      There is not a way around the Task Scheduler at this time.

                      The /silent option on the command line should supress the pop-up of the dialog. You will want to keep a log file (Help file -> Using Beyond Compare -> Command Line and Scripting-> Scripting reference -> Log command) to track successful completions or errors.
                      Aaron P Scooter Software

                      Comment

                      • Aaron
                        Team Scooter
                        • Oct 2007
                        • 15997

                        #12
                        I was hoping performing the Move command would leave a redirect (similar to moving threads), but it did not.

                        The following posts were moved to
                        http://www.scootersoftware.com/vbull...ead.php?t=4295
                        since they were BC2 Scripting questions.
                        Aaron P Scooter Software

                        Comment

                        Working...