Need to write a script, basically text processing

Discussion in 'OT Technology' started by Euclid, Jan 8, 2009.

  1. Euclid

    Euclid New Member

    Joined:
    Apr 19, 2004
    Messages:
    8,139
    Likes Received:
    0
    Location:
    Nashville, TN
    I need to automate the following process:

    1. Scan through an xml file looking for <image> tags
    2. Process the href and get the filename.gif
    3. Search a directory tree for filename.ai (same file name, different extension)
    4. If an AI file is found, replace the full path of the GIF with the new path to the AI
    5. Save the modified xml file

    This will be used on a Mac several times a day by a pretty novice user so I'd like to avoid a command-line solution. I was thinking some kind of AppleScript or Automator thing that we could drag and drop the XML file onto to process it. I suppose it could be a perl script or something that gets called from Automator / AppleScript.

    It's pretty straightforward, but I haven't done any programming in many years. Any guidance would be appreciated.
     
  2. Euclid

    Euclid New Member

    Joined:
    Apr 19, 2004
    Messages:
    8,139
    Likes Received:
    0
    Location:
    Nashville, TN
    Oh wow, Automator makes this super easy. Now for the fun task of writing the perl or python script.
     
  3. DouggieJ

    DouggieJ OT Supporter

    Joined:
    Nov 1, 2007
    Messages:
    8,126
    Likes Received:
    0
    Location:
    New York, NY USA
    Use Perl, it's great for stuff like this. I can help if you run into a problem.
     

Share This Page