I really hope someone can help me!
I have to make a script that everytime a new file is droped in a folder on a mac the script has to send the file to another mac on the same network.
The script I have made is not sending the file to the other mac (I can get it working when I send from one folder to another on the same mac)
How can it be done?
on adding folder items to this_folder after receiving these_items
tell application “Finder”
set the destination_disk to disk “afp://pdfmacmacintosh:@192.168.1.21/pdfmacmacintosh”
repeat with i from 1 to number of items in these_items
set downloadedFile to item i of these_items
set the theFileInfo to the info for downloadedFile
set oldFileSize to 0
set fileSize to the size of theFileInfo
repeat while fileSize is not equal to oldFileSize
set oldFileSize to fileSize
delay myDelay
set the theFileInfo to the info for downloadedFile
set fileSize to the size of theFileInfo
end repeat
if the name extension of the theFileInfo is in the graphicExtList then
move downloadedFile to destination_disk
end if
end repeat
end tell
end adding folder items to
to copy a file to a network volume, the volume must be mounted first.
Then the path to this volume ist just the name of the disk (and its subfolders)
Here is one possible solution:
property graphicExtList : {"pdf"}
property myDelay : 5
on adding folder items to this_folder after receiving these_items
tell application "Finder"
set destination_disk to "afp://pdfmacmacintosh:@192.168.1.21/pdfmacmacintosh"
set disk_name to last word of destination_disk
if not (exists disk disk_name) then
try
mount volume destination_disk
on error
display dialog "an error occured while mounting disk " & disk_name
return
end try
end if
repeat with i in these_items
set downloadedFile to contents of i as alias
set oldFileSize to 0
set fileSize to the size of (info for downloadedFile)
repeat while fileSize is not equal to oldFileSize
set oldFileSize to fileSize
delay myDelay
set fileSize to the size of (info for downloadedFile)
end repeat
if the name extension of the theFileInfo is in the graphicExtList then
move downloadedFile to (disk_name as alias)
end if
end repeat
end tell
end adding folder items to
if the file should replace an existing document,
add replacing yes to the move-line
Model: G5 dual 2,5 GHz
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
But maybe I don´t understand or write someting wrong. The volume is called “pdfmacmacintosh” when mounted on my macs desktop. When i try to send a file nothing happens.
I have changed “set disk_name to last word of destination_disk” to “set disk_name to first word of destination_disk” bacause I want the file to be placed in a subfolder.
Is the path wrong? (I have also tried only with “pdfmacmacintosh”)
property graphicExtList : {“pdf”}
property myDelay : 5
on adding folder items to this_folder after receiving these_items
tell application “Finder”
set the destination_disk to “pdfmacmacintosh/Public”
set disk_name to first word of destination_disk
if not (exists disk disk_name) then
try
mount volume destination_disk
on error
display dialog "an error occured while mounting disk " & disk_name
return
end try
end if
repeat with i in these_items
set downloadedFile to contents of i as alias
set oldFileSize to 0
set fileSize to the size of (info for downloadedFile)
repeat while fileSize is not equal to oldFileSize
set oldFileSize to fileSize
delay myDelay
set fileSize to the size of (info for downloadedFile)
end repeat
if the name extension of the theFileInfo is in the graphicExtList then
move downloadedFile to (disk_name as alias)
end if
end repeat
end tell