Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

AppleScript and TextEdit

I am looking to have the command

tell application "Finder" to set theFiles to files of theFolder as alias list

repeat with eachFile in theFiles

tell application "TextEdit"


activate


makenewdocumentat the front

set TiffInfo to do shell script "/usr/bin/exiftool -EXIF -Artist " & quoted form of POSIX path of eachFile

set the text of the front document to TiffInfo

end tell

end repeat


To save the out put of

set TiffInfo to do shell script "/usr/bin/exiftool -EXIF -Artist " & quoted form of POSIX path of eachFile

into one file and send it to a separate file for each time the command runs?

How can I change the comma

Posted on Apr 8, 2014 1:17 PM

Reply
Question marked as Best reply

Posted on Apr 8, 2014 2:30 PM

For a start, nix the entire TextEdit thing. At best, it's completely unnecessary, at worst it's a huge bloat to your script.


Instead, since it seems that all you want is a resulting text file that contains the exiftool output. Since you have that in a variable TiffInfo, you can just write that to a file within your do shell script command:


do shell script "/usr/bin/exiftool -EXIF -Artist " & quoted form of POSIX path of eachFile & " > /path/to/output.txt"


This will write the output to /path/to/output.txt. Just change that path as appropriate, including using variable substitution to create a dynamic file name (other than saying you want each output in a different file you don't give any hint as to what those files should be called.

5 replies
Question marked as Best reply

Apr 8, 2014 2:30 PM in response to Jade Curtis

For a start, nix the entire TextEdit thing. At best, it's completely unnecessary, at worst it's a huge bloat to your script.


Instead, since it seems that all you want is a resulting text file that contains the exiftool output. Since you have that in a variable TiffInfo, you can just write that to a file within your do shell script command:


do shell script "/usr/bin/exiftool -EXIF -Artist " & quoted form of POSIX path of eachFile & " > /path/to/output.txt"


This will write the output to /path/to/output.txt. Just change that path as appropriate, including using variable substitution to create a dynamic file name (other than saying you want each output in a different file you don't give any hint as to what those files should be called.

Apr 15, 2014 10:57 PM in response to Jade Curtis

As written, this script will create a file called 'output.txt' with the result of the exiftool command. Any existing file will be deleted.


If you want to append the data to the file, use '>>' rather than '>'


If you want unique file names just build a unique filename variable (e.g. using some kind of counter, or based on the source file name, etc.) and use that instead of '/path/to/output.txt'


The options are almost limitless. It's up to you to decide what you want it to do.

AppleScript and TextEdit

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.