AppleScript error -10000 when writing to dropbox directory - applescript

I have pasted together an apple script to save email attachments to a directory. Everything works fine, but when I set the output to a dropbox directory, I get an error message:
Result:
error "Mail got an error: To view or change permissions, select the item in the Finder and choose File > Get Info." number -10000
The line producing the error is the one starting with save anAttachment to... in the following script:
tell application "Mail"
set theMessages to messages of mailbox "Inbox" of account "xxx#yyy.zzz"
repeat with theMessage in theMessages
set theOutputFolder to ("/.../Dropbox (Company)/") as string
repeat with anAttachment in (get mail attachments in theMessage)
set theAttachmentName to name of anAttachment
set theSavePath to theOutputFolder & theAttachmentName
save anAttachment in theSavePath
end repeat
end repeat
end tell
In a non-dropbox directory everything works.
The flags of the dropbox directory are set as follows:
~ $ ls -FLAG -lhd# Dropbox\ \(Company)
drwx------# 15 username staff 480B Apr 8 13:52 Dropbox (Company)/
com.apple.FinderInfo 32B
I tried to run chmod go+rw on the directory, but that did not help.
GetInfo on the directory yields:
Changing everyone to Read&Write does not help either.

Whilst you get to the bottom of what is preventing you from writing out to folders other than your Downloads folder (which presumably includes subfolders in the Downloads folder), here's a barebones script that should save mail attachments to the folder ~/Downloads/Mail Attachments/.
I've put a filter on the messages being acted upon as retrieving every message in a mailbox is potentially very costly. This retrieves messages from the previous three days:
tell application id "com.apple.SystemEvents" to tell (make new folder ¬
with properties {name:"~/Downloads/Mail Attachments"}) to set ¬
directory to the POSIX path
tell application id "com.apple.Mail"
set _M to a reference to (every message in the inbox whose ¬
date received > ((my date named 0.0) - 3 * days))
repeat with A in _M's mail attachments
set f to the directory & "/" & A's name
save A in (f as POSIX file)
end repeat
end tell
You could perhaps add code to migrate the "Mail Attachments" folder from your Downloads folder to your Dropbox folder.

I was able to write the attachments to any directory I wanted by changing the part where I write to opening a file handle, and using using that to write the attachment into the directory. Instead of save anAttachment in theSavePath I use
set fp to open for access theSavePath with write permission
write (anAttachment) to fp
close access fp
That does the trick, though it does not explain why the original method did not work...

Related

applescript: how to copy real file instead of alias, but recursively

I am using the following script to copy certain folder content from my hard-drive on a usb-Stick. Since the folder content might change, I am using aliases.
The script used to work perfectly, but since I had to make changes in my folder structure, I now have sometimes an alias of an alias (workaround of the script, won´t go into that).
Problem is that the script seems to only convert the first level of alias-folders, but if there is an alias for a file within an alias for a folder, it copies the file-alias.
I wonder if it is possible to tell the script to recursively go through every level of the folder (ie every file) and copy the original file instead.
Thanks!
Peter
ps: exemplary folder structure of source folder:
alias of folder 1
alias of folder 1-1
alias of file a, alias of file b
alias of folder 2
alias of file c
--> first a dialogue
display notification "hello, get folder ready"
delay 5 --> allow time for the notification to trigger
set theDialogText to "choose source"
display dialog theDialogText
--> Result: {button returned:"OK"}
--> now computing
set the backupSource to (choose folder) as alias
set theDialogText to "choose destination"
display dialog theDialogText
--> Result: {button returned:"OK"}
set the backupDestination to (choose folder) as alias
display notification "maybe this takes a while..."
delay 6 --> allow time for the notification to trigger
--> now copy
tell application "Finder"
activate
with timeout of 600 seconds --> equeals 10 Minutes
set everyAlias to every item of folder backupSource
repeat with thisAlias in everyAlias
set originalFile to (original item of thisAlias)
duplicate originalFile to backupDestination
end repeat
end timeout
end tell
``````````
I feel that the the line "repeat thisAlias in everyAlias" doesn´t do its job and goes only one level down, ie it converts the alias on the first level and not all other aliases within this alias-folder
I don't have a quick fix, but rather programming advice: it's time to add debugging. In this case, I suspect your script is not operating on the files you intend to use. So what's it doing instead?
For example, near the beginning,
set debugOn to true
or better
property debugOn : true
Then right before your duplicate command,
if debugOn then display dialog ¬
"Copying thisAlias: " & return & (thisAlias as text) & return & ¬
"of originalFile: " & return & originalFile buttons "OK" default button 1
…and so forth. You can leave these if debugOn then… checks throughout your code with dialogs or even different modes of behavior, and just change it to property debugOn : false once it's working. Having it all there is also great for the inevitable day you need to edit the script, but it's aged enough you've forgotten all its nuances.
Maybe this following AppleScript code will help you accomplish what you're looking for?
tell application "Finder"
set sourceFolder to choose folder with prompt "CHOOSE SOURCE"
set destinationFolder to choose folder with prompt "CHOOSE DESTINATION"
set nestedFolders to a reference to (entire contents of sourceFolder)
set aliasFiles to a reference to every alias file of nestedFolders
set aliasFiles to contents of aliasFiles
repeat with i from 1 to count of aliasFiles
set thisItem to item i of aliasFiles
if not (exists of original item of thisItem) then
delete thisItem
end if
end repeat
set aliasFiles to a reference to every alias file of nestedFolders
set originalFiles to (original item of aliasFiles) as alias list
duplicate originalFiles to destinationFolder
end tell

Add vcard to Contacts with Mail rules and Applescript

I receive a lot of customer vcards to a specific email address. I want to automatically add the vcards to my contacts through the Mail rules and an AppleScript.
I searched a lot and found something. I modified it a bit. And the opening and adding process works fine. But only when I choose a file. I can't get the file into a variable from the mail message. I tried it but it won't work.
Here is my code so far:
tell application "Mail"
set att to attachment
end tell
set thefile to att
tell application "Contacts"
activate
open thefile
end tell
tell application "System Events" to keystroke return
If I delete line 1, 2 and 3 and write in line 4 "set thefile to choose file" then it will work - if I choose a file.
But the first three lines I tried something out, but without any success.
So my question is, how can I get the file from the message?
Thank you
Yours sincerely,
Chris
Solution:
set Dest to ((path to desktop folder) as string)
tell application "Finder" to make new folder in Dest with properties {name:"TempFiles"} -- create TempFiles folder
Set Dest to Dest & "TempFiles:"
tell application "Mail"
activate -- not sure is mandatory, but I prefer to see selected mails !!
set ListMessage to selection -- get all selected messages
repeat with aMessage in ListMessage -- loop through each message selected
set AList to every mail attachment of aMessage -- get all attachements
repeat with aFile in AList -- for each attachement
if (downloaded of aFile) then
set Filepath to Dest & (name of aFile)
do shell script "touch " & (quoted form of (POSIX path of Filepath)) -- required because "Save" only works with existing file !
save aFile in (Filepath as alias) as native format
end if
end repeat -- next file
end repeat -- next message
end tell
tell application "Finder" to set CardList to every file of folder Dest whose name extension is {"vcf"}
tell application "Contacts"
activate
repeat with aCard in CardList
open aCard
delay 1
tell application "System Events" to keystroke return
end repeat
end tell
delay 2
-- tell application "Finder" to delete folder Dest
The file attached from email respond to the 'save" command, but not to 'open'. Then, you must first save the attached files, and later, move them to next application (add in 'Contacts' in your case).
The attachement is a member of a list of 'mail attachement' of a message : keep in mind that there could be many files attached.
Also, you can only save the attached file if its 'downloaded' attribute is true.
Last, but not least, it seems that the "save" instruction which was working nice in Snow Leopard, does not work the same in El Capitain : the file where to save must exist before the "save"...this is why I added the "touch" command to create it first (just create the entry in the tempFiles folder).
I also add at bottom of script the open vCard with the enter key to validate in Contact. You may have to add a delay to leave sometime for your computer to process the card.
if the keys broke does not work in your case, please check System Preferences accessibility settings to allow your computer to let your script control your Mac.
I added as much comments as possible to make it clear...may be too much !
set Dest to ((path to desktop folder) as string)
tell application "Finder" to make new folder in Dest with properties {name:"TempFiles"} -- create TempFiles folder
Set Dest to Dest & "TempFiles:"
tell application "Mail"
activate -- not sure is mandatory, but I prefer to see selected mails !!
set ListMessage to selection -- get all selected messages
repeat with aMessage in ListMessage -- loop through each message selected
set AList to every mail attachment of aMessage -- get all attachements
repeat with aFile in AList -- for each attachement
if (downloaded of aFile) then
set Filepath to Dest & (name of aFile)
do shell script "touch " & (quoted form of (POSIX path of Filepath)) -- required because "Save" only works with existing file !
save aFile in (Filepath as alias) as native format
end if
end repeat -- next file
end repeat -- next message
end tell
tell application "Finder" to set CardList to every file of folder Dest whose name extension is {"vcf"}
tell application "Contacts"
activate
repeat with aCard in CardList
open aCard
tell application "System Events" to keystroke return
end repeat
end tell
-- tell application "Finder" to delete folder Dest
As you can see, I filter the content of the temp folder with only files with extension 'vcd'...just in case your selected emails contain also other type of file which Contact can't handled.
At end of the script, I delete the temp folder. however, until you test it, I set this last row as a comment only (more safe !)

Applescript to attach files and then send email to a recipient works if the script is on DT or in Doc folder, but not if placed in Dropbox folder

I am running Apple OS X 10.11.1 on a Macbook Pro. I use OpenOffice Calc ver 4.1.2 Macros to download SQL data from the internet, do calculations on the data, then create pdf files of the results, which are sent out to folks. The Emailing routines built into OpenOffice Basic work fine on a PC running Windows 7, but on the Mac, The Recipient and Subject fields are not passed to the Mac Mail.app. To solve the problem, I test to see if the file path is PC centric or Mac Centric, and if Mac Centric, I create a text file that has the Mac Centric paths to all the pdf files, then call an Applescript that reads the text file data, adds a subject line and recipient EM address, attaches the pdf files to the email message, then send the email to the recipient, without any intervention from the user. If the script is on the Desktop or in the Documents folder, it works fine, but not if it is placed in my Dropbox folder. I Get the "Network file permission error. (-5000). I tried to fix the File Permissions by going to Dropbox preferences, holding the options key down and clicking the "Fix Permissions" button, but that does not work either.
Can anyone tell me what to do to fix this. I have included the Applescript and text file so you can see what happens.
on run
(* tell application "Finder"
open file "somefile.txt" of folder of (file (path to me))
end tell *)
set myPath to (path to me) as text
set MME_path to POSIX path of myPath
set b to MME_path
set text item delimiters to "/"
set d to {}
set c to text items of b
set myhome to item 3 of c
-- display dialog MME_path & " " & myhome
set myPrefsFile to item 2 of c & "/" & item 3 of c & "/" & item 4 of c & "/" & item 5 of c & "/EM-Eargv.txt"
open for access myPrefsFile
set PrefsContents to read myPrefsFile using delimiter {","}
close access myPrefsFile
set thesubject to item 1 of PrefsContents
set thebody to ""
set theSender to item 2 of PrefsContents
set theAddress to item 3 of PrefsContents
set theAttachment to item 4 of PrefsContents
set theAttachment1 to POSIX file theAttachment
set theAttachment to item 5 of PrefsContents
set theAttachment2 to POSIX file theAttachment
set theAttachment to item 6 of PrefsContents
set theAttachment3 to POSIX file theAttachment
set theAttachment to item 7 of PrefsContents
set theAttachment4 to POSIX file theAttachment
--set userCanceled to false
--try
-- set dialogResult to display dialog ¬
-- "Path to file is " & theAttachment & " POSIX " & theAttachment1 buttons {"Cancel", "OK"} ¬
-- default button "OK" cancel button ¬
-- "Cancel" giving up after 15 ¬
-- default answer (long user name of (system info))
--on error number -128
-- set userCanceled to true
--end try
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:thesubject, content:thebody}
tell newMessage
set visible to true
set sender to theSender
make new to recipient at end of to recipients with properties {name:theSender, address:theAddress}
tell content
make new attachment with properties {file name:theAttachment1} at after the last paragraph
make new attachment with properties {file name:theAttachment2} at after the last paragraph
make new attachment with properties {file name:theAttachment3} at after the last paragraph
make new attachment with properties {file name:theAttachment4} at after the last paragraph
end tell
end tell
delay 3
send newMessage
end tell
delay 3
(*
tell application "Mail"
quit
end tell
*)
end run
The Text File is called EM-Eargv.txt
EM-Docs Files FYI.,”Your Name”,”YourEMaddress”,file:///Users/admin/Documents/Dropbox/EM-Docs/Sends/Doc1.pdf,file:///Users/admin/Documents/Dropbox/EM-Docs/Sends/Doc2.pdf,file:///Users/admin/Documents/Dropbox/EM-Docs/Sends/Doc3.pdf,file:///Users/admin/Documents/Dropbox/EM-Docs/Sends/Doc4.pdf,
You will have to update this text file with your own Name and email address plus change the path to whatever your is and place 4 short PDF files, named Doc1.pdf, Doc2.pdf, Doc3.pdf and Doc4.pdf in a folder called "Sends", before this applescript will send the email to you.
I can send you a short OpenOffice Calc document that creates the Text File with the correct path file data for your computer's configuration but I do not see how to attach the Calc.ods file into this request.
I run the entire example I have from a directory called "EM-Docs" That I can create a Zip file to be downloaded, but again, I do not see a way to attach a zip file to this request.
I'm guessing, it's this code block that's throwing the error:
open for access myPrefsFile
set PrefsContents to read myPrefsFile using delimiter {","}
close access myPrefsFile
Place some display dialog messages to debug and find the exact code, like so:
display dialog "About to read file"
open for access myPrefsFile
set PrefsContents to read myPrefsFile using delimiter {","}
close access myPrefsFile
display dialog "Just finished reading file" & return & (PresContents as string)
But here's the thing, if the problem is the open for access conflict with Dropbox, you don't HAVE to open for access a file if all you're doing is reading it. Just removed the open/close access lines, and try that:
display dialog "About to read file"
set PrefsContents to read myPrefsFile using delimiter {","}
display dialog "Just finished reading file" & return & (PresContents as string)
If, for some reason you do need to open file access, you could always quit Dropbox, do the file work, then launch Dropbox.

Applescript to copy each file individually to target folder

I have all these movies in .dvdmedia format and I want to covert them all to a smaller file size such as .mp4.
But what I need to do is create an applescript that will copy the individual file to a folder 'Conversion'. Once the file in the folder is deleted it copies the next item and deletes the previous.
I've completed an Automation script that once the item is added to the folder is starts formatting the file through TurboHD then deletes the file and moves the converted item to another folder 'Completed'
Does anyone able to help me with this?
Please note that the location of the movies are on a NAS drive
there :) I coded the following. Please note to save it as an Application with Stay open after run handler checked.
You have to set the source and the target path to the paths in your environment.
Finally you have to set the return value. The value sets the interval in seconds to wait until next execution. If each of your conversions takes about an hour, I think I would check every 5 minutes meaning the handler has to return 300.
-- The idle-Handler defines a repetitive task
-- Note: Save as Application with option "Stay open after run handler"
on idle
-- define the folders to watch
set theSourceFolder to (POSIX file "/Users/myHomeFolder/Desktop/Conversion_Source") as alias
set theTargetFolder to (POSIX file "/Volumes/myMountedVolume/Conversion") as alias
-- check the contained files (get visible files only because of .DS_Store etc.)
tell application "System Events"
set availableSourceFiles to every file of theSourceFolder whose visible is true
set filesOfTargetFolder to files of theTargetFolder whose visible is true
end tell
-- if no more source file is available, quit this script
if (count of availableSourceFiles) = 0 then
quit
end if
-- if the target folder is empty start move
if (count of filesOfTargetFolder) = 0 then
-- get the first item from source folder
set sourceFile to (first item of availableSourceFiles) as alias
-- use the Finder to copy the file
tell application "Finder"
-- duplicate the file to the target folder
duplicate sourceFile to theTargetFolder
-- move the source file to trash after copy
move sourceFile to trash
end tell
end if
-- the integer returned is the time to wait (in seconds)
-- here: two minutes
return 120
end idle
Enjoy, Michael / Hamburg

Applescript copy files to mounted volume; test for file(s) already exists

I am writing a script to allow students to upload their files to a shared folder on teacher's computer in a computer lab (same network). I have a working script that, when executed, will duplicate all files in the folder UPLOAD on the student machine to the folder SUBMISSIONS on the teacher's machine. However, if a file already exists on the teacher machine, the script hangs.
I need to be able to test for the presence of individual files on the teacher machine and either (a) pop a message that says "this file already exists, rename it and upload again" or (b) append something to the file name to differentiate it...a random number or "copy 1" etc.
Ideally I want it to run as a folder action. When a file is added to the "UPLOAD" folder it will automatically be sent to the teacher. But I don't want files to copy over files of the same name...or for the script to hang.
Any thoughts or alterative approaches would be welcome.
Here's my code:
set home_path to path to home folder as string
set work_folder to alias (home_path & "Desktop:" & "Upload")
try
mount volume "afp://[LOGIN INFO].local/Submissions"
set this_folder to result as alias
tell application "Finder"
tell application "Finder"
duplicate every file of work_folder to this_folder
end tell
eject this_folder
end tell
end try
I think that it would help if your try-block had an on-error block to inform you about any errors.
try
# try stuff here
j # this will compile but will throw a runtime error and you can see the error
on error error_message number error_number
display alert "Error: " & error_message & return & return & (error_number as text)
end try
OK. I tried again to write some code. Here is my version.
It does a couple of things differently than the code posted by the original poster.
It copies the files and folders into a new folder on the server with a time-stamp to cope with the problems of whether some of the files already exist on the server.
I changed the wording of the duplicate statement from duplicating every "file" to duplicating every "item" so that folders are duplicated too.
I put in an on-error block in the try-statement to display any errors.
I activate Finder so that you can see the progress window.
I pop up a dialog at the end if there were no errors.
I had a problem that I had to fix:
On the server, I had to enable write permissions for the client or I got a -5000 error.
I think that the following code should work pretty well. It's almost 100% AppleScript. It only uses one call to the shell and that is to get the current date and format it for the time-stamp for new folders created on the server.
# set the path to the "work_folder" where the files are to be uploaded
set home_path to path to home folder as string
set work_folder to alias (home_path & "Desktop:" & "Upload")
# duplicate the files and folders in work_folder to the server
try
# TODO set the name of your server here
set the_volume to mount volume "afp://32-bit.local/Submissions"
set destination_path to the_volume as text
set folder_name to getTimeStamp()
tell application "Finder"
activate
set new_folder to make new folder at alias destination_path with properties {name:folder_name}
duplicate every item of work_folder to new_folder
eject the_volume
display alert "Successfully uploaded the files and folders"
end tell
on error error_message number error_number
if error_number is not equal to -128 then
display alert "Error: " & error_message & return & return & (error_number as text)
end if
end try
# This function returns the current date and time as a time-stamp of the form yyyy-mm-dd-hh-ss
# This function uses a shell script because it's just a lot easier to do than in AppleScript
on getTimeStamp()
set time_stamp to do shell script "date '+%Y-%m-%d-%H-%M-%S'"
return time_stamp
end getTimeStamp
Here's another idea for debugging. You can put in calls to "display dialog" to be able to know where your script is failing:
display dialog "Entering script"
set home_path to path to home folder as string
display dialog "home_path: " & home_path
set work_folder to alias (home_path & "Desktop:" & "Upload")
display dialog "work_folder: " & work_folder as string
try
mount volume "afp://32-bit.local/Submissions"
set this_folder to result as alias
display dialog "this_folder: " & this_folder as string
tell application "Finder"
display dialog "Inside of the first tell application Finder"
tell application "Finder"
display dialog "About to call duplicate"
duplicate every file of work_folder to this_folder
display dialog "Just returned from calling duplicate"
end tell
display dialog "About to call eject"
eject this_folder
display dialog "Just returned from call to eject"
end tell
on error error_message number error_number
display alert "Error:" & error_message & return & return & (error_number as text)
end try
display dialog "Exiting script"
Another debugging technique is to log output to a text file.
Another debugging technique is to purchase the AppleScript debugger:
http://www.latenightsw.com/sd4/index.html
I believe that this debugger costs $200.00 that's too pricey for me, but I've used other debuggers and debuggers are wonderful tools that let you "peek inside" of your script while it's running to see the value of variables and to trace which lines of code are being executed.
This script will copy each file over to the mounted volume. If a file exists with the same name at the destination it will add a number to the end of the copy file name and try that.
Example:if test.doc exists in the folder already then the script will try and copy it with the name test_1.doc and so on..
The original file is never renamed and the older files are never overwritten.
The script is fully commented to explain what it is doing.
** Update2 **
The copy to destination code is now in it's own handler.
The original files are labeled by the finder label index 6 (green) to indicate successful copied.
This will also stop the same original file from being copied twice by using the index colour as a check. If it is labeled index label 7 it will be ignored.
You could if you want move the successful copied files to another folder out of the way using the script. But I have not done this in this script.
set home_path to path to home folder as string
set work_folder to alias (home_path & "Desktop:" & "Upload")
set counter to ""
global counter
--try
set this_folder to mount volume "afp://myMac/UserName/"
this_folder as text
tell application "Finder" to set theFiles to every file of work_folder as alias list #GET ALL FILES OF LOCAL FOLDER AS ALIASES
tell application "Finder" to set theRemoteFiles to (every file of ((this_folder & "Submissions:" as string) as alias)) #GET ALL FILES OF REMOTE FOLDER -- ONLY NEEDED FOR COUNT CHECK LATER
repeat with i from 1 to number of items in theFiles #PROCESS EACH LOCAL FILE
set this_item to item i of theFiles #GET A LOCAL FILE
tell application "Finder" to set LabelIndex to label index of this_item
if LabelIndex is not 6 then
tell application "Finder" to set this_name to displayed name of this_item #GET ITS DISPLAYED NAME
tell application "Finder" to set this_extension to name extension of this_item #GET ITS EXTENSION NAME i.E "txt"
set realName to (do shell script "echo " & quoted form of this_name & "| awk -F '" & quoted form of this_extension & "' '{print $1}'") #GET ITS NAME WITHOUT EXTENSION NAME
set counter to 1 # SET A NUMBER TO ADD TO THE FILE NAME IF THE FILE NAME EXIST ALREADY IN THE REMOTE FOLDER
my checkName(this_name, realName, this_item, this_extension, theRemoteFiles, this_folder) # CALL TO HANDLER THAT WILL DO THE CHECKING AND COPYING
end if
end repeat
tell application "Finder" to eject this_folder
# THE CALL TO THE HANDLER INCLUDES VARIABLES THAT ARE NOT GLOBAL OR PROPERTIES BUT NEED TO BE PASSED ON TO IT I.E(this_name, realName, this_item, this_extension, theRemoteFiles, this_folder)
on checkName(this_name, realName, this_item, this_extension, theRemoteFiles, this_folder)
# (1) IF THE NUMBER OF theRemoteFiles IS GREATER THAN 0 THEN FILES EXIST IN THE REMOTE FOLDER AND MAY CONTAIN FILES WITH THE SAME NAMES AS THE LOCAL ONES. PROCESS..
# (2) IF THE NUMBER OF theRemoteFiles IS NOT GREATER THAN 0.THEN FILES DO NOT EXIST IN THE REMOTE FOLDER AND THE LOCAL ONES CAN JUST BE COPIED OVER.
if (count of theRemoteFiles) is greater than 0 then # (1)
try
my copyOver(this_item, this_folder, this_name)
on error errMssg #WE USE not overwritten ERROR TO TRIGGER THE RENAME THE DESTINATION FILE NAME TO INCLUDE A NEW NUMBER.
--tell application "Finder" to set label index of this_item to 6
if errMssg contains "not overwritten" then
set this_name to (realName & counter & "." & this_extension)
set counter to counter + 1 #WE SETUP THE FILE NAME NUMBER FOR THE POSSIBLE NEXT RUN
# RUN THE HANDLER AGAIN WITH THE CHANED DETAILS
my checkName(this_name, realName, this_item, this_extension, theRemoteFiles, this_folder)
end if
end try
else # (2)
my copyOver(this_item, this_folder, this_name)
end if
end checkName
on copyOver(this_item, this_folder, this_name)
# THE -n OPTION IN THE SHELL COMMAND TELLS CP NOT TO OVERWRITE EXISTING FILES. AN ERROR OCCURE IF THE FILE EXISTS.
# THE -p OPTION IN THE SHELL COMMAND TELLS CP TO PRESERVE THE FOLLOWING ATTRIBUTES OF EACH SOURCE FILE IN THE COPY:
# modification time, access time, file flags, file mode,
#user ID, and group ID, as allowed by permissions. Access Control
#Lists (ACLs) and Extended Attributes (EAs), including resource
#forks, will also be preserved.
# THE -v OPTION IN THE SHELL COMMAND TELLS CP TO USE VERBOS MODE. WHICH GIVES US A BETTER CLUE OF THE ERROR
set theResult to (do shell script "cp -npv " & quoted form of (POSIX path of this_item) & space & quoted form of (POSIX path of (this_folder & "Submissions:" as string) & this_name))
if theResult contains "->" then
tell application "Finder" to set label index of this_item to 6
else
tell application "Finder" to set label index of this_item to 7
end if
end copyOver

Resources