Force copy of older files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nsteffy
    Visitor
    • Jan 2014
    • 9

    Force copy of older files

    I have a simple script (see below) I'm running that is copying files from one webserver to another. I have a similar script that does a binary compare of the files beforehand, giving the ability to select specific files to be copied. In the script below, parameter 4 is a list of files to be copied, 1 and 2 are the two server locations, and 3 is obviously the log file name. This script works great in almost all situations. However, in the specific scenario I have now, the compare is returning differences between two image files, which is correct. The issue is that the left side files are older than the right side files, and I believe this is causing the script to not push those files. Is there a way I can bypass the date check and force the older files to be pushed? We often receive image assets from clients, and sometimes the "new" file is actually older from a timestamp perspective. I realize we could likely touch each file on the left first, but it would be preferable to preserve the original timestamp on the file. Any thoughts or help is appreciated. Thanks


    (Also of note, following the script in actual BC window leaves me with the correct files left, with both the left and right sides selected. Clicking sync returns "nothing to do", and copy brings up the dialog to specify a direction, could this be a dialog issue that I'm not accounting for?)



    log verbose %3
    criteria binary
    filter %4
    load %1 %2
    expand all
    select all.files
    copy left->right
  • Aaron
    Team Scooter
    • Oct 2007
    • 16026

    #2
    Hello,

    By "following the script in actual BC", you mean to load the folders and paste the filter string, then perform an Edit menu -> Expand All, Edit menu -> Select All Files, then Copy Left to Right, correct?

    The Sync command would not Sync Update, since update only copies Newer and Orphan files, and will not copy Older files. Instead, a regular Copy should be used (as you do in the script example).

    The script itself looks fine. Since you have an all.files selection, you technically do not need a criteria binary scan. If you wanted to select left.diff.files, then the scan is useful and can limit the number of copies you are attempting to perform:
    log verbose "%3"
    criteria binary timestamp
    filter "%4"
    load "%1" "%2"
    expand all
    select left.diff.files left.newer.files left.older.files left.orphan.files
    copy left->right


    If you copy and paste the "%4" text into the filter box in the GUI, is it filtering correctly as you expect? A small syntax error here could be excluding items you do not intend, changing what is actually copied. By copying and pasting the text/string into the Filters toolbar button, you can preview the filter in the graphical interface.
    Aaron P Scooter Software

    Comment

    • nsteffy
      Visitor
      • Jan 2014
      • 9

      #3
      Yes you are correct about "following the script in actual BC", in that I load the actual BC GUI program, load the left and right folders, copy the filter in, and execute the commands based on the drop down menus. To respond to your last thought, yes the filter is working exactly as expected inside of the GUI.

      I notice you changed the "select all.files" line to be more specific in selecting the left side. How does this differ from all.files? Would the copy command react differently if only the left side files were selected, despite the "copy left->right" command?

      Going back to the middle of your response, I realize that the sync wouldn't work, hence why I'm doing a copy, but the copy is still ignoring the older files. Is that expected behavior?

      Comment

      • Aaron
        Team Scooter
        • Oct 2007
        • 16026

        #4
        No, but without selecting the specific differences you are copying all files (equal, too) from left to right. If you are going to copy everything, then you would not need to run a criteria binary (which takes additional time to scan).

        Do you have the Prompt to overwrite newer files disabled? If this prompt is defaulted to No to All in the Options dialog -> Folder Views, Confirmations, that might explain the behavior you are seeing. Also, which version of BC3 are you currently running (Help menu -> About dialog)?
        Aaron P Scooter Software

        Comment

        • nsteffy
          Visitor
          • Jan 2014
          • 9

          #5
          Sorry for the delay on this, had to take some time off this project for other things.

          We are using Beyond Compare 3, version 3.3.3 (build 14128)

          I looked into the BC instance on the server that is running the script, and discovered that as you had postulated, in Options -> Folder Views -> Confirmations, the option for "Confirm overwriting newer files", was indeed checked. Also of possible note, in the next section down "Synchronize confirmations", the option "Prompt" was selected (rather than "Yes to All" or "No to All").

          I updated BC on that server so that the confirm newer files option was NOT checked, however I left the synchronize section at "Prompt", since in theory it should no longer be prompting for newer files anyway. I also modified the script, replacing the "select all.files" line with the "select left....." line that you provided in a previous response.

          Unfortunately, this made no difference in the results of executing the script. It still runs with no errors, but it also does not overwrite the newer file with the older one, leaving the files with differences.

          Might you have any other suggestions/options to get this functioning as desired? Truthfully, I would be surprised if there isn't some way, but nothing seems to be doing the trick. Might moving to BC4 get us the results we're looking for?


          To recap the problem:
          -The script is intended to copy file(s) from one server to another (using the "copy" command)
          -The file(s) are specified in the filter command, so only the files intended to be copied are involved/selectable in the compare/copy
          -Executing the script commands manually inside the BC GUI window filters and selects the correct file(s) as expected, preparing for what would seem a proper file copy
          -The script runs perfectly if the left side file(s) have a newer timestamp than the right side, but fails to copy any files where the left side timestamp is older than the right side
          -We want to be able to overwrite newer files with older ones


          Thank you very much for your help thus far, and continuing. Any further insights or suggestions are greatly appreciated.

          Comment

          • Aaron
            Team Scooter
            • Oct 2007
            • 16026

            #6
            Hello,

            Are you running the command line with /silent? This would suppress the prompt and pick the default behavior. Running with the optionrompt would be the option used in script, which would prompt, and if suppressed would then not overwrite. The option you want is yes-to-all, and the option should be at the top of the script. If you could repost your command line call and your current script, that would help. I can then run with your specific script to see what might be happening.

            We should be able to get this working in BC3. I would recommend updating to 3.3.10 to get all the most recent bug fixes.
            Aaron P Scooter Software

            Comment

            • nsteffy
              Visitor
              • Jan 2014
              • 9

              #7
              Here is an example of a command being run. This is being run by a C# library accessing the windows command shell. For security reasons I have replaced the actual server and folder names, but this should be enough to replicate the experience. Essentially, 3 servers: one that runs the script, one source, one destination. Source and destination file/folder structures are identical (moving files from developement to QA webservers). Logs are saved temporarily in the same directory that holds the BC script. And obviously, we are using the /silent flag.

              /C BComp "\\scriptservername\sub1\sub2\script.txt" "\\sourceServer\folder1\folder2" "\\destServer\folder1\folder2" "\\scriptservername\sub1\sub2\dynamicLogFilename.t xt" ".\folder3\fileWithDifferences.txt" /silent

              (If unfamiliar, the /C command simply tells the windows command window to close after completing the command)

              For completeness, here is the updated script that is running (Yes I am aware the criteria binary is not necessary, and have left it in while we resolve this issue, if only for laziness. However since it IS still present in my script, I thought it reasonable to include):

              log verbose %3
              criteria binary
              filter %4
              load %1 %2
              expand all
              #select all.files
              select left.diff.files left.newer.files left.older.files left.orphan.files
              copy left->right

              I will be trying the change to "Yes to all" as soon as I am able to find time, hopefully sometime today.
              Thanks again.

              Comment

              • nsteffy
                Visitor
                • Jan 2014
                • 9

                #8
                For more completeness, here is the output from the logfile. Again, names replaced, but matching the replacements made above.

                3/13/2014 5:10:22 PM >> log verbose \\scriptservername\sub1\sub2\dynamicLogFilename.tx t
                3/13/2014 5:10:22 PM >> criteria binary
                3/13/2014 5:10:22 PM >> filter .\folder3\fileWithDifferences.txt
                3/13/2014 5:10:22 PM >> load \\sourceServer\folder1\folder2 \\destServer\folder1\folder2
                3/13/2014 5:10:22 PM Load comparison: \\sourceServer\folder1\folder2 <-> \\destServer\folder1\folder2
                3/13/2014 5:10:22 PM >> expand all
                3/13/2014 5:10:22 PM >> #select all.files
                3/13/2014 5:10:22 PM >> select left.diff.files left.newer.files left.older.files left.orphan.files
                3/13/2014 5:10:22 PM >> copy left->right
                3/13/2014 5:10:22 PM Script completed in 0.17 seconds
                Last edited by nsteffy; 14-Mar-2014, 02:35 PM.

                Comment

                • nsteffy
                  Visitor
                  • Jan 2014
                  • 9

                  #9
                  Here is a screenshot of the BC window after completing the script tasks, perhaps that would be helpful. Again sorry, for security reasons the server names have been removed.

                  Comment

                  • Aaron
                    Team Scooter
                    • Oct 2007
                    • 16026

                    #10
                    I set this up and verified. If you are still running with /silent, you need to add "option confirm:yes-to-all" as the second line of your script:

                    log
                    option confirm:yes-to-all
                    criteria
                    filter

                    Does this get the script copying for you?
                    Aaron P Scooter Software

                    Comment

                    • nsteffy
                      Visitor
                      • Jan 2014
                      • 9

                      #11
                      There it is... I think you had mentioned this before but I thought it was in relation to the options selected inside the GUI. I didn't realize that adding /silent would make it ignore those.

                      Yes, adding the option confirm:yes-to-all command fixed the problem.
                      Thank you for your time and persistence helping with this, much appreciated.

                      Comment

                      • Aaron
                        Team Scooter
                        • Oct 2007
                        • 16026

                        #12
                        /silent itself doesn't ignore the option, but it needs to be defined separately in script. Adding /silent just suppresses *all* dialogs, which then cancels the dialog when it pops up, and can make it a bit difficult to troubleshoot.

                        In general, (for other users that might hit this post), it is good to add /silent after the script has run a couple of times and is working as expected. /silent suppresses not just the interface, but any dialogs or error prompts.
                        Aaron P Scooter Software

                        Comment

                        Working...