simple script selective archive and upload FTP

Hi I need help in creating a simple script that does following

  1. User selects a folder / right clicks on a folder
  2. A .zip is created of certain files that are in that folder (e.g. wav files smaller than 10MB and all .txt files)
  3. Upload the zip file to an ftp server
  4. Delete the local zip file.

I’ve tried using Automator but I can’t get it to create the zip with only the files I’m interested in.
Thank you for any suggestions!

Hi Carles,

welcome to MacScripter

Actually this could be done just with a shell script.
But I’m not very familiar with shell scripts, so this AppleScript (with lots of shell calls) should do it.
The filter options are as you described
The name of the file will be “Archive_[folder name]_[yyyymmdd]” ([yyyymmdd] is the current date).
Replace the values of the properties with your FTP data (the property ftppath must end with a slash)

--the server information
property ftpserver : "[url=][/url]" --ftp server 
property ftppath : "/pub/" --the directory on the server (for the root directory, leave this empty)
property server_username : "myusername" --server_username (if you want to get asked for it everytime, leave this empty)
property server_password : "¢¢¢¢¢¢" --server_password (if you want to get asked for it everytime, leave this empty)

set inputFolder to (choose folder with prompt "Select folder" without invisibles)
set inputFolderPOSIX to quoted form of POSIX path of inputFolder
set fName to name of (info for inputFolder)
set ZIPfile to quoted form of ((POSIX path of (path to temporary items)) & "Archive_" & fName & "_" & (do shell script "date +%Y%m%d" & ".zip"))
do shell script "find " & inputFolderPOSIX & " -maxdepth 1 \\( -size -10M -iname '*.wav'  -or -iname '*.txt' \\) -print -exec zip -jqmo9 " & ZIPfile & " {} \\;"
	do shell script "curl " & ftpserver & ftppath & " -u " & server_username & ":" & server_password & " -T " & ZIPfile
	do shell script "rm -r " & ZIPfile
on error e
	display dialog e
end try

Notes for used zip parameters: 
-j   junk (don't record) directory names
-q   quiet operation 
-m   move into zipfile (delete files)
-o   make zipfile as old as latest entry
-9   compress better 

Thank you so much, Stefan. You really helped me out of this problem!