No announcement yet.

Creating a batch file with Beyond Compare?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating a batch file with Beyond Compare?

    At my workplace we use Beyond Compare to deploy web sites. We examine the current source, compare it to what's in production, and produce a new version of production to deploy. We then use BC again to perform the actual deployment (done by another person). He takes the merged version, then simply uses Folder Sync with "Mirror" mode to copy all the new/changed files, and delete any removed files from the server in one shot.

    It works great. However, it would be nice if we could eliminate the need to use BC for the final step. Instead, it would be ideal if we could generate batch files that use XCOPY and DEL to take all the changes from the local folder and commit them to the target server.

    Today I created such a batch file by hand. I used the Folder Comparison Report to list out the changed and deleted files, then I used some Search/Replace in a text editor to turn the lines into batch commands. It's was easy, but tedious.

    I ended up not even bothering with individual files for the XCOPY. Instead, I loaded my folders in BC, showed only differences, then used the Copy to Folder to create a "patch" of just the new or changed files into a new folder. Then my batch file simply copies the entire folder over to the server. And I only need individual file commands to delete the orphans that no longer belong on the server.

    I would love it if BC did something like this for me. It could take any Folder Sync command, and instead of actually performing it, copy all the files to a new folder and create a batch file to deploy them and plus delete the "right side orphaned" files. At some point, you would type in the true target folder that would go into the batch file as the root of the target paths for the XCOPY and DEL commands.

    That would be an amazing feature that my team would use at least once a week.

    I would also be open to any other means that BC could be used to create a deployment "package" that can be run at a different time. It could even be an "installer" exe it creates. Just take whatever operations a Sync would do and package them up in an exe. When run, BC would not need to be installed. It would be good if someone could examine the changes it would make before running it.

  • #2

    We do not have a tool for exporting a self contained batch file, but we do have a few other tools you may find useful:

    1) Copy filename from the right-click menu: Open the Folder Compare, select your files, and Right click, Copy File name. This will contain the full path to the files and may be useful for parsing by another program. The XML Summary Folder Compare Report may also be useful in this regard.

    2) Open With: Beyond Compare supports a customizable Open With command. You can define any command line call here, including one you create that will read in and then create the batch file for you.

    3) BCSS - BC specific SnapShot files. You can create these from the Tools menu -> Snapshots. They contain the file and folder structure, and some file attributes (such as timestamp, size, etc) without the entire file. They can be loaded in a Folder Compare for easy viewing and comparison (and can store CRC codes for content comparison).

    4) Script automated - Script can be called as part of an automated solution, and has access to basic sync commands such as Sync->Mirror. Since Mirror can delete files, it is recommended to test with test files in the graphical interface to see if it behaves as expected. Otherwise, a combination of selection commands and copy commands could be used to perform a more customized Copy/Sync/Delete.

    5) Folder Sync Session type (not automated): Our Folder Sync Sessions have easy to customize rules under the Session Settings' Sync tab to set up custom syncs. Unfortunately, these cannot be called with Script currently.

    Do any of these additional tools help with your current task?
    Last edited by Aaron; 28-Apr-2009, 04:39 PM. Reason: added ending question.
    Aaron P Scooter Software


    • #3
      Ah, I never noticed the Copy Filename command before. That will help a lot when creating a batch file that contains several delete commands. Thanks.

      As for the new/changed files, I use Copy To Folder, like I said, with Keep Relative Folder structure to create a patch. Then I can use a single XCOPY command to deploy the whole folder.

      It was creating all the delete commands that was a pain. Copy Filename doesn't allow me to copy relative filenames, but I can make all the paths relative in a text editor easily enough.