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

Re: clip to open two files and then replace specific lines

Expand Messages
  • flo.gehrke
    ... Hi Don, I would propose to name the base files as base-001.txt. base-002.txt etc up to base-999.txt. So you could automatically find the latest version
    Message 1 of 3 , Oct 27, 2012
      --- In ntb-clips@yahoogroups.com, Don <don@...> wrote:
      >
      > I have two files. I will call one the update file as it has new
      > data and the other the base file as it is the base I am trying to
      > keep current.
      > (...)
      > So tasks I need to do...
      > 1. find the two files and tell my clip to work on these two files
      > 2. find the lines that need to be replaced and replace them
      > 3. save the base file with a sequential number so that I can always go
      > to the most recent file but don't lose the prior file.
      >
      > I am stumped already on the first part ... how to select my
      > two files.

      Hi Don,

      I would propose to name the base files as base-001.txt. base-002.txt etc up to base-999.txt. So you could automatically find the latest version with the following clip and save the updated version with an increased number. Tested with Ntb Pro 7.1:


      ^!Set %Files%=^$GetFileFirst(^$GetDocumentPath$;"base*.txt";;Name)$

      :Loop
      ^!Set %Last%=^$GetFileName(^%Files%)$
      ^!Set %Files%=^$GetFileNext$
      ^!IfEmpty ^%Files% Open
      ^!Goto Loop

      :Open
      ^!CloseFileFind
      ^!Open ^%Last%
      ; Insert updating here
      ^!Info [L]Updating lines should follow here.^PClick OK to save this^Pfile with an increased number

      :Save
      ^!Set %Nr%=^$StrCopyRight("^$GetFileName(^#)$";3)$
      ^!Inc %Nr%
      ^!Set %Nr%=^$StrCopyRight("00^%Nr%";3)$
      ^!Save as base-^%Nr%.txt


      Do you still have any problem with updating the base files? If so, drop us a line, and we'll look after that...

      Regards,
      Flo
    Your message has been successfully submitted and would be delivered to recipients shortly.