Thursday, December 14, 2017

#1 2017-11-28 05:58:22 am

Noovicio
Member
Registered: 2016-10-15
Posts: 20

Not having permission to save text file

Hello, I'm having problems trying to make a text file inside a newly created folder. I'm getting the "You don't have permissions...." I've tried several different approaches but still can't get the text file to save on the new folder created.
This is what I have so far. This is the last of many tries before I gave up and came here asking for help, I tried shell script, textedit etc, but I'm not having any luck. sad
Thanks for your help, really appreciate it.

Applescript:

set theContent to "djdklsfjklewjfiorjsdlndsklfjkld"
set thePath to (path to desktop as text) & "HD:User:etc:Job Files:1-New Jobs:"
set theSubject to "subject"

tell application "Finder"
   make new folder at thePath with properties {name:theSubject}
end tell

tell application "TextEdit"
   --activate
   make new document
   --set name of document 1 to theSubject
   set text of document 1 to theContent as text
   save document 1 in (path to desktop as text) & "test.txt"
   close
end tell

Offline

 

#2 2017-11-28 06:04:46 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: Not having permission to save text file

You can't treat paths as files -- you need actual files. Try this:

Applescript:

set theContent to "djdklsfjklewjfiorjsdlndsklfjkld"
set thePath to (path to desktop as text)
set theSubject to "subject"

tell application "Finder"
   make new folder at folder thePath with properties {name:theSubject}
end tell

set theDest to (thePath & "subject:test.txt") as «class furl»
tell application "TextEdit"
   --activate
   make new document
   --set name of document 1 to theSubject
   set text of document 1 to theContent as text
   save document 1 in theDest
   close
end tell


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2017-11-28 06:44:17 am

Noovicio
Member
Registered: 2016-10-15
Posts: 20

Re: Not having permission to save text file

Thanks Shane, and thanks for your ASOC book too! smile

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)