ChiefJones
Mitglied
Thread Starter
- Dabei seit
- 29.05.2005
- Beiträge
- 45
- Reaktionspunkte
- 0
hallo Applefreunde,
ich habe hier ein Anliegen: Ich möchte den Prozess automatisieren, dass wenn ich irgendeine Datei in ein bestimmtes Verzeichnis kopiere, soll diese gleich auf mein FTP-Server hochgeladen werden. Ich habe hier zwar ein Script, klappt aber nicht so ganz wie ich es mag. Es lädt nur in das Hauptftpverzeichnis.
Ich möchte es aber in ein ganz bestimmtes haben.
Also, wie kann ich es umschreiben ?
Danke für die Hilfe im Voraus.
Grüße
property dialog_timeout : 3
property BenutzerName : "benutzer"
property passwort : "passwort"
-- Server anpassen und den Pfad zum gewünschten Directory abändern.
-- hier ist das Problem, "/dasverzeichnis" wird nicht beachtet
property serverpfad : "ftp://XXXserverXXX.de/dasverzeichnis"
on adding folder items to this_folder after receiving added_items
my prepareMode()
try
tell application "Finder"
set the folder_name to the name of this_folder
end tell
set the item_count to the number of items in the added_items
if dialog_timeout > 0 then
set alert_message to "Ordneraktion:" & return & return
if the item_count is greater than 1 then
set alert_message to alert_message & ((the item_count as text) & " neue Dateien werden hochgeladen “" & the folder_name) & "”."
else
set alert_message to alert_message & "Eine neue Datei wird hochgeladen “" & the folder_name & "”."
end if
activate
display dialog the alert_message buttons {"•"} default button 1 with icon 1 giving up after dialog_timeout
end if
if class of added_items is not list then
set added_items to added_items as list
end if
repeat with dieDatei in added_items
set dieDatei to dieDatei as text
set LokalerPfad to quoted form of POSIX path of alias dieDatei
set DateiName to do shell script "basename " & LokalerPfad
set UeberOrdner to quoted form of POSIX path of this_folder
set ScriptBefehl to "cd " & UeberOrdner
set ScriptBefehl to ScriptBefehl & "; curl -T " & quoted form of DateiName & " -u " & BenutzerName & ":" & passwort & " " & serverpfad
do shell script ScriptBefehl
end repeat
if dialog_timeout > 0 then
activate
display dialog "Ordneraktion:" & return & return & "Fertig!" buttons {"•"} default button 1 with icon 1 giving up after dialog_timeout
end if
on error errMsg
display dialog errMsg
end try
end adding folder items to
on prepareMode()
if BenutzerName = "" then
set BenutzerName to text returned of (display dialog "Bitte Benutzernamen eingeben" buttons {"OK"} default button 1 default answer "")
end if
if passwort = "" then
set passwort to text returned of (display dialog "Bitte Passwort eingeben" buttons {"OK"} default button 1 default answer "")
end if
end prepareMode
ich habe hier ein Anliegen: Ich möchte den Prozess automatisieren, dass wenn ich irgendeine Datei in ein bestimmtes Verzeichnis kopiere, soll diese gleich auf mein FTP-Server hochgeladen werden. Ich habe hier zwar ein Script, klappt aber nicht so ganz wie ich es mag. Es lädt nur in das Hauptftpverzeichnis.
Ich möchte es aber in ein ganz bestimmtes haben.
Also, wie kann ich es umschreiben ?
Danke für die Hilfe im Voraus.
Grüße
property dialog_timeout : 3
property BenutzerName : "benutzer"
property passwort : "passwort"
-- Server anpassen und den Pfad zum gewünschten Directory abändern.
-- hier ist das Problem, "/dasverzeichnis" wird nicht beachtet
property serverpfad : "ftp://XXXserverXXX.de/dasverzeichnis"
on adding folder items to this_folder after receiving added_items
my prepareMode()
try
tell application "Finder"
set the folder_name to the name of this_folder
end tell
set the item_count to the number of items in the added_items
if dialog_timeout > 0 then
set alert_message to "Ordneraktion:" & return & return
if the item_count is greater than 1 then
set alert_message to alert_message & ((the item_count as text) & " neue Dateien werden hochgeladen “" & the folder_name) & "”."
else
set alert_message to alert_message & "Eine neue Datei wird hochgeladen “" & the folder_name & "”."
end if
activate
display dialog the alert_message buttons {"•"} default button 1 with icon 1 giving up after dialog_timeout
end if
if class of added_items is not list then
set added_items to added_items as list
end if
repeat with dieDatei in added_items
set dieDatei to dieDatei as text
set LokalerPfad to quoted form of POSIX path of alias dieDatei
set DateiName to do shell script "basename " & LokalerPfad
set UeberOrdner to quoted form of POSIX path of this_folder
set ScriptBefehl to "cd " & UeberOrdner
set ScriptBefehl to ScriptBefehl & "; curl -T " & quoted form of DateiName & " -u " & BenutzerName & ":" & passwort & " " & serverpfad
do shell script ScriptBefehl
end repeat
if dialog_timeout > 0 then
activate
display dialog "Ordneraktion:" & return & return & "Fertig!" buttons {"•"} default button 1 with icon 1 giving up after dialog_timeout
end if
on error errMsg
display dialog errMsg
end try
end adding folder items to
on prepareMode()
if BenutzerName = "" then
set BenutzerName to text returned of (display dialog "Bitte Benutzernamen eingeben" buttons {"OK"} default button 1 default answer "")
end if
if passwort = "" then
set passwort to text returned of (display dialog "Bitte Passwort eingeben" buttons {"OK"} default button 1 default answer "")
end if
end prepareMode