Very Basic: Reusing the name of a document

I want to create a script that exports all the stories from InDesign into a single text file and names the text file the original documents name plus “-stories” and .txt (or 3-letter extension of filetype. Any ideas?

If the stories aren’t too long, your script can get them from InDesign then use the Scripting Additions write command to append them to a text file. The first story will have to create the file, of course.

If the stories are too large, you’ll need to write temporary files then combine them. The shell command ‘cat’ handles this much faster than applescript would.

You might want to use a droplet onto which the InDesign file is drag-n-dropped, then its name will be easily available within the applescript droplet; or you may want to use an applet with a choose file dialog box. Either way, separating the name from the file path is a single command (either info for or get name). If for some reason the script operates on an already open InDesign file, InDesign’s dictionary lists both full path and full name as properties.