#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    1
    Rep Power
    0

    Deleting many lines of text between specified characters?


    Hi,
    First post here and I'm hoping one of the experts can help please. I have a text file that looks like this:

    --- Start paste ---

    [BlackfordLane.jpg]
    File name = BlackfordLane.jpg
    Directory = C:\Docs\My Videos\PROJECTS\Thames Path Walk Projects\TP03 Project\Geograph Photos\GeoDay2\
    Compression = JPEG, quality: 87, subsampling OFF
    Resolution = 96 x 96 DPI
    File date/time = 19/01/2012 / 15:01:23

    - IPTC -
    Object Name - s bridge over the River Thames is not a footbridge but carries pipes.

    - COMMENT -
    Thames Path on Blackford Lane heading towards Blackford Farm, east of Castle Eaton.

    [Castle Eaton Church.jpg]
    File name = Castle Eaton Church.jpg
    Directory = C:\Docs\My Videos\PROJECTS\Thames Path Walk Projects\TP03 Project\Geograph Photos\GeoDay2\
    Compression = JPEG, quality: 87, subsampling OFF
    Resolution = 72 x 72 DPI
    File date/time = 19/01/2012 / 14:03:55

    - EXIF -
    Make - FUJIFILM
    Model - FinePix2600Zoom
    Orientation - Top left
    XResolution - 72
    YResolution - 72
    ResolutionUnit - Inch

    - COMMENT -
    Castle Eaton Church

    [CastleEaton-2.jpg]
    File name = CastleEaton-2.jpg
    Directory = C:\Docs\My Videos\PROJECTS\Thames Path Walk Projects\TP03 Project\Geograph Photos\GeoDay2\
    Compression = JPEG, quality: 75
    Resolution = 0 x 0 DPI
    File date/time = 18/01/2012 / 15:40:05

    - COMMENT -
    The Red Lion, Castle Eaton
    A warm welcoming pub on a cold winter's day, with the River Thames running at the bottom of the garden.

    This is what I want to get as a result:

    BlackfordLane.jpg
    Thames Path on Blackford Lane heading towards Blackford Farm, east of Castle Eaton.

    Castle Eaton Church.jpg
    Castle Eaton Church

    CastleEaton-2.jpg
    The Red Lion, Castle Eaton
    A warm welcoming pub on a cold winter's day, with the River Thames running at the bottom of the garden.

    My first line of attack is to try for a Regex expression that will Find everything (for example) between the ']' of '[BlackfordLane.jpg]' and the '-' of '- COMMENT -'? That would leave only a little tidying up, I think.

    But so far that's eluded me after a couple of hours. The best I could come up with was the following to delete all lines from File name... to File date/time (with the Replace box empty):

    File name = .*\nDirectory = .*\nCompression = .*\nResolution = .*\nImage dimensions = .*\nPrint size = .*\nColor depth = .*\nNumber of unique colors = .*\nDisk size = .*\nCurrent memory size = .*\nFile date/time = .*\n

    But that's only part of the task and seems very inelegant.

    Any suggestions please?

    --
    Terry, East Grinstead, UK
  2. #2
  3. Turn left at the third duck
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Location
    Nelson, NZ
    Posts
    112
    Rep Power
    93
    Mmm...
    I think this is a cross-post.

    As I suggested elsewhere in more detail:
    Search: (?sm)\[([^]]+.jpg)\].*?- COMMENT -(\r\n[^[]*)
    Replace: \1\2
  4. #3
  5. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,760
    Rep Power
    9397

IMN logo majestic logo threadwatch logo seochat tools logo