我正在寻找一些可以监视文件夹的软件,当您更改文件时它会自动上传。我不喜欢将远程目录挂载为本地文件夹的程序,因为如果您的网络连接速度很慢,它们会非常慢。
答案1
答案2
如果您运行的是 OSX,则可以使用 AppleScript 通过在特定文件夹中设置“文件夹脚本”来实现此目的。它会将每个新文件上传到 FTP 服务器,甚至在文件夹内的文件被编辑时进行更新。
以下是示例脚本可以更新为能够作为文件夹脚本运行:
(*
upload
Uploads the given file or folder to the given remote ftp folder using "curl".
If you need user/password to login to such server, append it to the URL. Eg:
ftp://user:[email protected]/dir/
Parameters:
filePath: file path, alias, posix path (a file or folder)
remoteDir: ftp directory (eg: "ftp://ftp.server.com/foo/" or "ftp://user:[email protected]/dir/")
Example:
upload(alias "path:to:dir:", "ftp://usernameHERE:[email protected]/html/docs/")
*)
to upload(filePath, remoteDir)
global baseLocalFolder, baseRemoteFolder, ftpHome, ftpDir
script nesteed
to guessNewDir(f) -- "/path/to/footest" --> /footest
set prevTids to AppleScript's text item delimiters
set AppleScript's text item delimiters to POSIX path of parent's baseLocalFolder
set f to item -1 of f's text items
set AppleScript's text item delimiters to prevTids
return f
end guessNewDir
to breakURL(d) --> "ftp://user:[email protected]/html/docs/" --> {"ftp://user:[email protected]", "/html/docs"}
set prevTids to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set ftpHome to "" & items 1 thru 3 of d's text items
try
set ftpDir to "/" & items 4 thru -1 of d's text items
on error
set ftpDir to "/"
end try
set AppleScript's text item delimiters to prevTids
return {ftpHome, ftpDir}
end breakURL
to processUnknownItem(f, remoteDir)
set f to f as text
if f ends with ":" then
processFolder(f, remoteDir)
else
do shell script "curl -T " & quoted form of POSIX path of f & space & quoted form of remoteDir
end if
end processUnknownItem
to processFolder(f, remoteDir)
set newDir to guessNewDir(POSIX path of f) --> "/footest"
try --> avoid existing dirs
if newDir is not "" then do shell script "curl -Q " & quoted form of ("MKD " & parent's ftpDir & newDir) & space & parent's ftpHome
end try
set itemList to list folder alias f without invisibles
repeat with i in itemList
processUnknownItem(alias (f & i), parent's ftpHome & parent's ftpDir & newDir)
end repeat
end processFolder
end script
set wasError to false
try
set filePath to filePath as Unicode text
if filePath does not contain ":" then set filePath to POSIX file filePath as Unicode text
if remoteDir does not end with "/" then set remoteDir to remoteDir & "/"
if filePath ends with ":" then --> mirror dir
-- MAKE DIRECTORY "TEST" IN EXISTING "/HTML/DOCS"
-- curl -Q "MKD /html/docs/test" ftp://user:[email protected]
set baseLocalFolder to filePath
set baseRemoteFolder to remoteDir
set {ftpHome, ftpDir} to breakURL(remoteDir) of nesteed --> {"ftp://user:[email protected]", "/html/docs"}
processFolder(filePath, remoteDir) of nesteed
else
do shell script "curl -T " & quoted form of POSIX path of filePath & space & quoted form of remoteDir
end if
on error msg number n
set wasError to true
end try
set baseLocalFolder to missing value
set baseRemoteFolder to missing value
set ftpHome to missing value
set ftpDir to missing value
if wasError then error msg number n
return
end upload
property |version| : 1.0
property author : "Pescados Software @ PescadosWeb.com"
property |date| : date "sábado, 17 julio 2004 22:20:27"
property license : "freeware, open-source"