|
|
Automator + BBedit... I'm too dumb
|
|
|
|
Mac Elite
Join Date: Jul 2001
Location: Switzerland
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
Senior User
Join Date: Oct 2000
Location: Midwest
Status:
Offline
|
|
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-
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jan 2004
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jul 2001
Location: Switzerland
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jan 2004
Status:
Offline
|
|
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 Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|