Append text from multiple files

I’m making a lot of small XML-files, and I want to merge them into a large one.
The idea is to make a folder action that reads the data from the newly created xml-file, and adds it at the end (appends) of a file called “bigfile.xml”. If bigfile does not exist, it should be created.

I think it sounds pretty easy, but I cannot figure it out. I’d be grateful for any help!

Eivind Andersen

You can read and write files with applescript, but if you’re not changing the xml in any way, it’s easier to just shell script.

for example…

do shell script(“cat theSourceFile >> bigfile.xml”)

or something fancier…
rm -f chr.lst
touch chr.lst
foreach f (ls chr?.txt)
foreach? echo “Appending file ‘$f’…”
foreach? cat $f >> chr.lst
foreach? endq

Try this:


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Thank you!

The last script worked fine when tried it. However, there seems to be a problem when trying to convert the script into a folder action.

I try to replace the two first lines with this:

on adding folder items to source_folder after receiving the_files ,

… but unfortunately the script halts. Any ideas?

Eivind Andersen