Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Applications > Automator + BBedit... I'm too dumb

Automator + BBedit... I'm too dumb
Thread Tools
workerbee
Mac Elite
Join Date: Jul 2001
Location: Switzerland
Status: Offline
Reply With Quote
Dec 2, 2005, 06:15 PM
 
Probably I'm headed totally the wrong way, but: I need to save the filename of about 300 XML files into a text file, and extract the e-Mail address from inside every one of these XML files into the same text file. I thought of using Automator and BBedit, but can't quite figure out how.

Anyone have any experience in this and is willing to share?

TIA!
MBP 15" 2.33GHz C2D 3GB 2*23" ACD
     
suthercd
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Dec 2, 2005, 08:05 PM
 
How about using Applescript and the XSLT scripting addition from Late Night Software. Depending on the files' location(s), you could create a droplet that would get the each file name, open each file, extract the data, save the file name and extracted data to one line per file in a text document. You could do it with Automator using some Finder actions and Textedit actions to get the file names, but I don't see the ability to extract the data from the proper XML class via Automator.

Give a bit more info about the project if you want more help.

C-
     
uberwrensch
Fresh-Faced Recruit
Join Date: Jan 2004
Status: Offline
Reply With Quote
Dec 2, 2005, 10:17 PM
 
Depending on the complexity within the xml files, I'd probably just do this on the command line or write a quick shell script. But I'd need more details to help you out in any tangible way. Give an example of the xml files and sample content.

Uber
PB17" | 1.33 | 1g | 80g
     
workerbee  (op)
Mac Elite
Join Date: Jul 2001
Location: Switzerland
Status: Offline
Reply With Quote
Dec 4, 2005, 10:47 AM
 
Thanks for the suggestions + help!

The whole little drama was about getting Mail adresses out of XML files for sending a reminder about Login data to users, and I decided I had to go some other way in the end: add this information into a newsletter CSV database where all these users were already entered anyway.

However, I'd still be curious about the wizardry done with BBEdit/Automator/AppleScript, so:

Those XML files are called NameSurname.wUser.xml (NameSurname then being the Login name a user has to enter for some protected parts of a website).

Its content:
Code:
<wUser version="1.0"> <password expires="" interval="" value="3b8a8420a929be3e051343edec32b548"/> <firstname value="Fester"/> <surname value="Bestertester"/> <email forwardextern="" value="[email protected]"/> <language value="de"/> <type value=""/> <environment root="" rootFiles=""/> (snippetysnip) <creation time="2005-11-15 18:39:18" /> </wUser>
MBP 15" 2.33GHz C2D 3GB 2*23" ACD
     
uberwrensch
Fresh-Faced Recruit
Join Date: Jan 2004
Status: Offline
Reply With Quote
Dec 4, 2005, 06:03 PM
 
I dunno about Automator and have only dabbled in Applescript, so I won't comment on that. Here's what I'd do--I'm lazy.

I'd just run a 'for' loop on the command line or stick into shell script like so:
Code:
#!/bin/sh for xmlfile in *.wUser.xml do echo "$xmlfile" | sed 's~\(.*\)\.wUser.xml~\1~' grep "<email" "$xmlfile" | sed 's~.*value=\"\(.*\)\"/>~\1~' done
I don't know how familiar you are with shell scripting but all that's doing is looking for all files that end in wUser.xml. Then, for each one spit out the "NameSurname" section and on the next line spit out the email address from within the xml file.

So the output from the script above will look like this:
Maybe that's not the end format you're wanting I don't know. Anyway, it's just a quick and dirty like I said.

HTH,

Uber
PB17" | 1.33 | 1g | 80g
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 11:11 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,