You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

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

Moving a file after text has been added.

I am adding a text line to the file and after doing so, I want the file moved to another folder.


tell application "Finder"

set the_file to ("Macintosh HD:Users:chipthomas:Dropbox:Apps:Attachments:Daily Live Net Sales Gmail:Daily Live Net Sales Gmail.csv" as alias)

set the_text to (read (the_file as alias))

set the_date to (creation date of the_file) as string

set the_date to word 1 of the_date & items ((count word 1 of the_date) + 2) thru ((count word 1 of the_date) + (count word 2 of the_date) + (count word 3 of the_date) + 3) of the_date & items ((count word 1 of the_date) + (count word 2 of the_date) + (count word 3 of the_date) + 5) thru -1 of the_date

set the_text to "\"Report Date\",\"" & the_date & "\"" & return & the_text

set the_file to open for access the_file as alias with write permission

write the_text to the_file as string

close access the_file

end tell


tell application "Finder"

move alias to "Macintosh HD:Users:chipthomas:Dropbox:IFTTT:Gmail"

end tell


The top part work, but the bottom does not.


Any suggestions?


Thanks

Chip

iMac 27" 5K, macOS 10.14

Posted on May 21, 2019 2:00 PM

Reply
Question marked as Top-ranking reply

Posted on May 23, 2019 8:17 AM

Replace the last three lines of the first tell segment with:


set the_number to open for access the_file as alias with write permission

write the_text to the_number as string

close access the_number


(171797)

Similar questions

10 replies

Moving a file after text has been added.

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