Loading ...
Sorry, an error occurred while loading the content.

Archive Bit not alway set when file changes.

Expand Messages
  • jwconklin
    I run this batch file (at end of message) as a scheduled task to backup two sperate files if they have changed every 10 Min. It seemed to work when it only run
    Message 1 of 2 , Jan 2, 2007
    • 0 Attachment
      I run this batch file (at end of message) as a scheduled task to
      backup two sperate files if they have changed every 10 Min.
      It seemed to work when it only run on one file(750 path), but now
      that I tried to add the second file (1000 path), changes
      made to the (1000 path) file can be viewed but are not backup because
      the archive bit is no set.
      If I set archive bit from a CMD window then it will work. I have only
      noticed this problem on the 1000 file.
      I had help from this group on testing the attrib and can not say I
      understand how it works.
      Is there a better way to backup a modified file as a scheduled task?

      Thanks



      @echo off
      Goto Start
      Backup MDI files to sever

      :START

      Set HOUR=%TIME:~0,2%
      Set MIN=%TIME:~3,2%
      Set MONTH=%DATE:~4,2%
      Set DAY=%DATE:~7,2%
      Set YEAR=%DATE:~10,4%


      for %%c in ("\\A2100-750\user\data\mdi.nc") do set flags=%%~ac
      set abit=%flags:~2,1%

      set printabit=%flags%
      echo %YEAR%-%MONTH%-%DAY%_%HOUR%%MIN% %PRINTABIT% 750>>log.txt

      if "%abit%"=="a" goto :copy
      goto :SKIP
      :copy
      COPY \\A2100-750\user\data\mdi.nc S:"\Engineering Files\Jim's
      Files\CNC_BACKUP\750\750 %YEAR%-%MONTH%-%DAY%_%HOUR%%MIN%-mdi.nc"
      ATTRIB -a \\A2100-750\user\data\mdi.nc

      :SKIP

      for %%c in ("\\A2100-1000\user\data\mdi.nc") do set flags=%%~ac
      set abit=%flags:~2,1%

      set printabit=%flags%
      echo %YEAR%-%MONTH%-%DAY%_%HOUR%%MIN% %PRINTABIT% 1000>>log.txt

      if "%abit%"=="a" goto :copy
      goto :EOF
      :copy
      COPY \\A2100-1000\user\data\mdi.nc S:"\Engineering Files\Jim's
      Files\CNC_BACKUP\1000\1000 %YEAR%-%MONTH%-%DAY%_%HOUR%%MIN%-mdi.nc"
      ATTRIB -a \\A2100-1000\user\data\mdi.nc

      :EOF
    • foxidrive
      ... Try this - it s untested though. Xcopy with the /M switch will only copy the file if the archive attribute is set, and will then reset the archive
      Message 2 of 2 , Jan 2, 2007
      • 0 Attachment
        On Tue, 02 Jan 2007 18:38:42 -0000, "jwconklin" <jwconklin@...> wrote:

        >I run this batch file (at end of message) as a scheduled task to
        >backup two sperate files if they have changed every 10 Min.
        >It seemed to work when it only run on one file(750 path), but now
        >that I tried to add the second file (1000 path), changes
        >made to the (1000 path) file can be viewed but are not backup because
        >the archive bit is no set.

        >Is there a better way to backup a modified file as a scheduled task?

        Try this - it's untested though. Xcopy with the /M switch will only
        copy the file if the archive attribute is set, and will then reset the
        archive attribute.

        The "for" and "XCOPY" lines are each on a single line in case
        they wrap.

        Any lines in column 1 have wrapped.

        @echo off
        :: Backup MDI files to server

        Set HOUR=%TIME:~0,2%
        Set MIN=%TIME:~3,2%
        Set MONTH=%DATE:~4,2%
        Set DAY=%DATE:~7,2%
        Set YEAR=%DATE:~10,4%

        for %%c in ("\\A2100-750\user\data\mdi.nc") do echo %YEAR%-%MONTH%-%DAY%_%HOUR%%MIN% File attributes are: "%%~ac" 750 >>log.txt
        XCOPY \\A2100-750\user\data\mdi.nc "S:\Engineering Files\Jim's Files\CNC_BACKUP\750\750 %YEAR%-%MONTH%-%DAY%_%HOUR%%MIN%-mdi.nc" /M

        Set HOUR=%TIME:~0,2%
        Set MIN=%TIME:~3,2%
        Set MONTH=%DATE:~4,2%
        Set DAY=%DATE:~7,2%
        Set YEAR=%DATE:~10,4%

        for %%c in ("\\A2100-1000\user\data\mdi.nc") do echo %YEAR%-%MONTH%-%DAY%_%HOUR%%MIN% File attributes are: "%%~ac" 1000 >>log.txt
        XCOPY \\A2100-1000\user\data\mdi.nc "S:\Engineering Files\Jim's Files\CNC_BACKUP\1000\1000 %YEAR%-%MONTH%-%DAY%_%HOUR%%MIN%-mdi.nc" /M
      Your message has been successfully submitted and would be delivered to recipients shortly.