Tapatalk

Search-Replace, find number replace with number+1

Search-Replace, find number replace with number+1

2
NewbieNewbie
2

    Jun 27, 2006#1

    Hello,

    I'm trying to find a somewhat automated way to replace some ASCII date / time fields in a Nikon NEF RAW digital image file. None of the various tools I've tried have gotten it right, but editing the binary file does work.

    Is it possible to specify a specific string - such as "xx:xx:xx" - and replace the first "xx" with "xx+1". For example finding "19:00:00" and replacing it with "20:00:00".

    Many thanks for any assistance. I've done some work with regex's in Perl before but I don't see a way to "inline script" variables, etc. into the search/replace in UltraEdit.

    Brian

    6,685587
    Grand MasterGrand Master
    6,685587

      Jun 27, 2006#2

      There are 2 problems:

      1) Regular expressions cannot be used if a binary file is opened in hex mode.

      2) Mathematical operations are not possible in regex.

      Solution: Modify the binary file with several Replace In Files. Replace In Files allows you to modify binary files with a regular expression.

      Here is the macro in UltraEdit style. Modify the red highlighted strings to your environment. The macro needs the property Continue if a Find with Replace not found checked.

      UnixReOff
      ReplInFiles RegExp "C:\Temp\" "*.raw" "22^(:[0-5][0-9]:[0-5][0-9]^)"
      "23^1"
      ReplInFiles RegExp "C:\Temp\" "*.raw" "21^(:[0-5][0-9]:[0-5][0-9]^)"
      "22^1"
      ReplInFiles RegExp "C:\Temp\" "*.raw" "20^(:[0-5][0-9]:[0-5][0-9]^)"
      "21^1"
      and so on
      ReplInFiles RegExp "C:\Temp\" "*.raw" "01^(:[0-5][0-9]:[0-5][0-9]^)"
      "02^1"
      ReplInFiles RegExp "C:\Temp\" "*.raw" "00^(:[0-5][0-9]:[0-5][0-9]^)"
      "01^1"

      The same macro in Unix or Perl style according to the engine you select with the first command:

      UnixReOn
      ReplInFiles RegExp "C:\Temp\" "*.raw" "22(:[0-5][0-9]:[0-5][0-9])"
      "23\1"
      ReplInFiles RegExp "C:\Temp\" "*.raw" "21(:[0-5][0-9]:[0-5][0-9])"
      "22\1"
      ReplInFiles RegExp "C:\Temp\" "*.raw" "20(:[0-5][0-9]:[0-5][0-9])"
      "21\1"
      and so on
      ReplInFiles RegExp "C:\Temp\" "*.raw" "01(:[0-5][0-9]:[0-5][0-9])"
      "02\1"
      ReplInFiles RegExp "C:\Temp\" "*.raw" "00(:[0-5][0-9]:[0-5][0-9])"
      "01\1"

      As you can see 23:xx:xx is not changed to 00:xx:xx because a change of day cannot be done.
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Jun 27, 2006#3

        Thanks for the quick reply!

        On a side note, I'm a little jealous that you live in Austria. My wife and I spent two weeks in Germany and Austria on our honeymoon and it was great. There was a monestary a little ways outside Munich call Andechs that had the best beer I've every had anywhere (and I've sampled a few :wink: ). That, Salzburg, and Hallstat in Austria were three of our favorite places we hit.