Sample scripts are provided as-is with no warranty of fitness for a particular purpose. These scripts are solely intended to demonstrate techniques for accomplishing common tasks. Additional script logic and error-handling may need to be added to achieve the desired results in your specific environment.
update_rss_feed.s
Really Simple Syndication, or as it is more commonly known, RSS, is a web format for publishing a feed of information that is regularly updated. RSS clients (like Firefox, Outlook, Google Reader, etc.) can subscribe to that feed and receive these regular updates.
A common use of Robo-FTP is to upload media files to a web site. You can also use Robo-FTP to update an RSS feed with information about the uploaded files.
This example uploads .mpg files to a web server and updates a related RSS feed with information about the uploaded files.
NOTE: This script sample does not display 100% correctly in a browser because it contains what the browser interprets as html tags (which are really xml tags we are updating with the script). Click the Download link to view the sample in the Robo-FTP script editor to see the complete script.
1 workingdir "C:\path\to\files"
2 archivedir "C:\archive\path"
3 :top
4 getnextfile "*.mpg" /oldest
5 iferror return $ERROR_SUCCESS
6 ftplogon "my_web_site"
7 sendfile %nextfile /archive
8 IFERROR RETURN
9 ***********************
10 * Update the RSS feed *
11 ***********************
12 SET filedatetime = %nextfiledatetime
13 DATETIMESUB filedatetime 5 /hour ;; Get time in GMT
14 ;; need to convert Sat Feb 17 11.00.22 2001 format to Mon, 21 Sep 2009 13:00:00 GMT format
15 SETLEFT DDD = filedatetime 3
16 SETMID MMM = filedatetime 3 5
17 SETMID dd = filedatetime 2 9
18 SETMID hh = filedatetime 2 12
19 SETMID mm = filedatetime 2 15
20 SETMID ss = filedatetime 2 18
21 SETRIGHT YYYY = filedatetime 4
22 SET day_date = DDD + ', ' + dd + ' '
23 SET month_year = MMM + ' ' + YYYY + ' '
24 SET hhmm = hh + ':' + mm + ':'
25 SET ssGMT = ss + ' GMT'
26 SET timestamp = day_date + month_year + hhmm + ssGMT
27
28 * Keep a local copy of the RSS feed without the last two lines
29 SET rss_file = "c:\rss\incomplete_rss_file.xml"
30 SET complete_rss_file = "c:\rss\rss.xml"
31 WRITEFILE rss_file '- ' /append
32 SET title = '
' + %nextfile + ' '
33 WRITEFILE rss_file title /append
34 SET description = '' + %nextfile + ' '
35 WRITEFILE rss_file description /append
36 SET pubdate = '' + timestamp + ' '
37 WRITEFILE rss_file pubdate /append
38 SET enclosure = '1" type="video/mpeg" />'
39 WRITEFILE rss_file enclosure /append
40 SET guid = 'http://mysite.com/' + %nextfile + ' '
41 WRITEFILE rss_file guid /append
42 WRITEFILE rss_file ' ' /append
43
44 COPY rss_file complete_rss_file
45 WRITEFILE complete_rss_file '' /append
46 WRITEFILE complete_rss_file '' /append
47 * Upload the updated RSS file *
48 SENDFILE complete_rss_file
49 IFERROR RETURN
50
51 * loop back to the top to see if there are more files to send *
52 goto top