On Apr 30, 2015, at 18:44, Christopher Stone <[email protected]> wrote:
>
> The Finder it seems doesn't like moving or duplicating items into a package,
> so I had to use the shell in my tests - but that's easy enough.
______________________________________________________________________
I should say AppleScripting the Finder to move or copy files into folder
'folder-name.pkg' failed.
BBEdit itself was able to do it without issue.
---------------------------------------------------------------------------------
set _folder to ((path to home folder as text) & "test_directory:find test
1:myTest.pkg:")
tell application "BBEdit"
save front text document to file (_folder & "test.txt")
end tell
---------------------------------------------------------------------------------
Here's a working prototype that will deal with saved or unsaved documents:
-----------------------------------------------------------------------------------
set arcFolder to ((path to home folder as text) & "test_directory:find test
1:myTest.pkg:")
set moveIt to false
set newDocName to do shell script "date '+Saved %Y.%m.%d · %H.%M.%S.txt'"
tell application "BBEdit"
tell front text document
if on disk = true then
if state modified = true then save
set bbFile to POSIX path of (get its file)
set moveIt to true
else
save it to file (arcFolder & newDocName)
end if
end tell
end tell
if moveIt then
set shCmd to "
bbFile=\"" & bbFile & "\";
dest=~/\"test_directory/find test 1/myTest.pkg/\";
newFileDest=\"$dest$(basename \"$f\")\";
if [ ! -f \"$newFileDest\" ]; then
mv \"$bbFile\" \"$newFileDest\";
else
echo \"File Collision!\";
fi
"
do shell script shCmd
end if
-----------------------------------------------------------------------------------
Note that I'm not handling any collisions (easy enough to do with a
date-suffix), neither am I doing any error-handling. I leave these as an
exercise for the reader.
--
Best Regards,
Chris
--
This is the BBEdit Talk public discussion group. If you have a
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].