How to back up a file on load/open only?

How to back up a file on load/open only?

5
NewbieNewbie
5

    Jul 25, 2007#1

    Hello All:

    I love that UE backs up on saving the file however, is there a way for it to back up when I open the file.

    I don't need a backup of the file I just edited, I need to backup the original in case I need to go back. :lol:

    thanks for any help on this,

    Paul

    6,675585
    Grand MasterGrand Master
    6,675585

      Re: New Way To Backup files......

      Jul 26, 2007#2

      Yes, that is possible. First turn off the automatical backup of UltraEdit.

      Next open Advanced - Tool Configuration and create a new tool with following settings:

      Tab Command
      Menu Item Name: Create Backup
      Command Line: copy "%f" "%f.bak"   or   copy "%f" "%p%n.bak"   or   copy "%f" "%p%f_bak%e"
      Working Directory: %p       no double quotes - important!
      Toolbar bitmap/icon (file path): whatever you like and have

      Tab Options
      Program Type: Dos Program
      Save Active File: checked
      Save all files first: unchecked

      Tab Output
      Command Output: Append to Existing
      Show DOS Box: unchecked
      Capture Output: unchecked
      Replace selected text with: No Replace

      Okay, now you have a tool which you can run whenever you want to create a backup of the current file.

      To run it automatically on every file open, following is necessary:

      Click on Macro - Delete All to delete all currently loaded macros.

      Click on Macro - Edit Macro and click on button New Macro.

      Enter as macro name for example BackupOnLoad. Uncheck both macro properties and click on button OK.

      Delete the existing 4 lines and add command RunTool "Create Backup" (name is case-sensitive!).

      Click on button Close and then on Yes.

      Click on Macro - Save All and save the macro for example into file BackupOnLoad.mac.

      Next click on Macro - Set Macro for File Load/Save.

      Use button Browse to select just saved macro file BackupOnLoad.mac with full path.

      At Macro Name to Execute on Load enter BackupOnLoad and set # of Times to 1.

      Click OK and close UltraEdit.

      Now the copy command to create a backup is always executed when you open a file, except when you open it via the recent file list. I don't know why there is a difference. I must report this to IDM and ask.

      By the way: There is also the command File - Make Copy/Backup for a quick manual backup where you can enter a name you like.
      Best regards from an UC/UE/UES for Windows user from Austria

      5
      NewbieNewbie
      5

        Jul 26, 2007#3

        wow, mofi

        thanks a bunch. this will save me some time everytime I have to backup a file to open it.

        thanks again for all your help,

        Paul

        6,675585
        Grand MasterGrand Master
        6,675585

          Feb 06, 2008#4

          If you want the current date in the backup file name, you need instead of tool command copy "%f" "%f.bak" following tool command line:

          "path to batch file\datebak.bat" "%f" "%p%n"

          The batch file datebak.bat must have following lines:

          @echo off
          set BAKFILE=%2
          set BAKFILE=%BAKFILE:~0,-1%_%DATE%.bak"
          copy %1 %BAKFILE% >nul


          That works only with Win2K or higher with command extensions enabled. Tested with WinXP SP2.

          Explanation:

          "%f" passes the current name of the file in long format with full path and with including the double quotes to the batch file. This parameter is stored in argument environment variable 1 called in the copy command with %1.

          "%p%n" passes the current file name in long format with full path but without ".extension" to the batch file. Now the batch file should append to this file name without extension an underscore, the current date, a period and the file extension bak.

          The problem is that first the double quote at end of the passed file name without extension must be removed to get a valid new file name. (On WinXP it would work also without removing the ", but that is not good practice). To do this the file name with path but without file extension is copied to a new environment variable. With %BAKFILE:~0,-1% the last character is removed from the variable which removes the double quote. _%DATE%.bak" appends in the same step the underscore, the current date as command date would output, the new file extension bak with the period and last the closing double quote.

          Example: "C:\Temp\Test File" becomes "C:\Temp\Test File_06.02.2008.bak"

          (Regional and language settings are set to Austria with date format typical for Europe).

          %date% is dynamically set on usage as it is described at bottom of large help for command set. Enter in a command prompt window set /? to get full help about command set.

            Feb 11, 2008#5

            psquillace wrote:I was kind of holding out until v14 came out to upgrade... will that make a difference.
            Currently not on this issue.

            The batch file is now working. The problem is that the system date format according to your regional and language settings contains / and this is interpreted by Windows as directory delimiter like \ . (Windows gets more and more Unix features with every new Windows version.) It is necessary to reformat the date string in the batch file.

            Test version of the batch file:

            @echo on
            set BAKFILE=%2
            set MYDATE=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%
            set BAKFILE=%BAKFILE:~0,-1%_%MYDATE%.bak"
            copy %1 %BAKFILE%

            Above was tested on Windows XP and the date string in the file name should be now in the format YYYY-MM-DD.

            Final version of the batch file:

            @echo off
            set BAKFILE=%2
            set MYDATE=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%
            set BAKFILE=%BAKFILE:~0,-1%_%MYDATE%.bak"
            copy %1 %BAKFILE% >nul
            Best regards from an UC/UE/UES for Windows user from Austria

            12
            Basic UserBasic User
            12

              Feb 15, 2008#6

              Nice stuff mofi, however it seems like something UE should be able to do on it's own eh :-)?

              In particular, the 'Make Copy/Backup' button you mentioned is a bit of a let down... it doesn't tie into UE's 'version backup' feature at all and is nothing more than a trimmed down version of the 'Save As' button... Kind of seems silly to have both of these, and ideally the 'Make Copy/Backup' button would apply the rules a user configures in the Backup section of UE config... then users like psquillace could just run a macro that calls the internal ID_ func equivilant for the Copy/Backup button...

              As it is though, you've inspired me to make a Tool for a button that will do this the way I would like from a VBscript, as I don't happen to like the fact that the Configuration options for version backup don't distinguish between a 'manual' save operation and a save that happens after answering yes when closing a file that's been modified... Ideally, the Copy/Backup button should have done this for me.

              6,675585
              Grand MasterGrand Master
              6,675585

                Feb 15, 2008#7

                I have already written a suggestion email to IDM for a "Backup only once per editing session" feature/setting for UltraEdit, UEStudio and UltraCompare and IDM support agreed that this is a good idea.

                If 1 request is enough too get this enhancement soon is not guaranteed. More requests send to IDM by email for such an enhancement will surely increase the priority of this enhancement.
                Best regards from an UC/UE/UES for Windows user from Austria

                12
                Basic UserBasic User
                12

                  Feb 15, 2008#8

                  I just sent the following to IDM... can anyone think of other ways of tweaking the way the version backup stuff works?

                  **********************************************************
                  Regarding the file backup and 'version backup' feature... I love that this was added, it's something I requested back in either version 9 or 10 days. However, I hope you might consider the following:

                  The 'Make Copy/Backup' toolbar button 'sounds' like it should actually make use of the 'version backup' UE configued options, but all it seems to be is a trimmed down version of the 'Save As' dialog, so I see no real value in it at all. It would make much more sense (to me) if it were to provide a way of 'manually' invoking the version backup feature. If you don't think it would be prudent to 'replace' the functionality of the current 'Make Copy/Backup' button (maybe people are using it, and would be caught off guard by a change) then maybe you'd consider these alternatives:

                  - an additional option in UE Configuration->File Handling->Backup->Version Backup section like "Use 'version backup' for 'Make Copy/Backup' button function (ID_FILE_MAKECOPY)...
                  - add an additional button/function specifically for this like 'Make Version Copy/Backup" (ID_FILE_MAKEVERBKUP)...

                  Besides this specifc functionality, another part of the version backup feature I find a bit cumbersome is the slight 'conflict' that it has with the existing 'Backup Files on Save' settings. If both options are being used, then only one should win out IMHO. As it stands, making a single change to a file, then closing and selecting 'yes' to save causes TWO backups of the file to be created... I'm sure you've got other old users 'trained' in the use of the .BAK extension, and might share my feelings that if they've only saved a change 'once' that we'd be happy with the .BAK file, and that 'subsequent' changes should then cause the versioning to kick in... Again, perhaps best left to an additional option like:

                  - Use .bak method for first save, then apply 'version backup' settings

                  ...or something similar.
                  **********************************************************

                  Comments?