Upload multiple pdfs to fetch

I work at a newspaper, and we are getting ready to upload our pdfs into a folder on our ftp server. I would like to make it automated using apple script and fetch. Here is the script I have so far. The files will be in multiple folders, like
A Section, B Section, C Section, etc… My question is, is there a way to tell fetch to upload all the files in a folder without using the file names, the reason is some nights there will be only 10 files and other nights there will be 20 files in a folder?

Any help is very appreciated :slight_smile:
Thanks

-- Get todays month
set themonth to month of (current date)

-- Get todays year
set theYear to year of (current date) as text

--Get today's day
set WDay to weekday of (current date) as text

-- Selecting the day Folder if it is less than 10 it adds a 0 in front
if day of (current date) is less than 10 then
	set theDay to "0" & day of (current date)
else
	set theDay to day of (current date) as text
end if


set theSource to "Out"
set theSourcehome to "Main EPS Pages"


-- Selecting the Month Folder
if month of (current date) is January then
	set theInput to theYear & "01" & theDay
else if month of (current date) is February then
	set theInput to theYear & "02" & theDay
else if month of (current date) is March then
	set theInput to theYear & "03" & theDay
else if month of (current date) is April then
	set theInput to theYear & "04" & theDay
else if month of (current date) is May then
	set theInput to theYear & "05" & theDay
else if month of (current date) is June then
	set theInput to theYear & "06" & theDay
else if month of (current date) is July then
	set theInput to theYear & "07" & theDay
else if month of (current date) is August then
	set theInput to theYear & "08" & theDay
else if month of (current date) is September then
	set theInput to theYear & "09" & theDay
else if month of (current date) is October then
	set theInput to theYear & "10" & theDay
else if month of (current date) is November then
	set theInput to theYear & "11" & theDay
else if month of (current date) is December then
	set theInput to theYear & "12" & theDay
end if

set myurl to ""

tell application "Fetch 4.0.3"
	with timeout of 6000 seconds
		open url myurl
		make new remote directory at beginning with properties {name:theInput}
		open remote directory theInput
		put into transfer window "" item alias "Macintosh HD:Users:comp1:Desktop:Main EPS Pages:A Section:Out:gta001.pdf" format Automatic without uniquename
		end timeout
end tell

Several comments, that I hope are taken as educational.

  1. In a script where you needed the current date several times, you would not call it every time, but rather set it to a variable once, and then use the variable thereafter.

set Today to (current date)
-- do several things with Today

Note that Jacques has suggested one way to get short dates in sortable order. Here is another that is faster because it does not involve the shell script call, but relies entirely on AppleScript. (I am not sure it works in Panther, however).


set {year:y, month:m, day:d} to (current date)
set theDate to (y * 10000 + m * 100 + d) as string

In Tiger you can use a record to get a piece of a date.


set Now to current date

set {weekday:WD} to Now --> Saturday -- an AppleScript key word (no quotes)
set WD1 to WD as number --> 7
set WD2 to 1 * WD --> 7

set {month:mm} to Now --> August -- an AppleScript key word (no quotes)
set mnth to 1 * mm --> 8

In the short date script, year * 10000 = 20060000
month * 100 = 800 → August is coerced to 8 for you
day is 5
20060000 + 800 = 20060800
add the day → 20060805
Convert to string “20060805” and done with the leading zeros we want if the month or day are single digits.