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 getrewind
5 getfile "*.mpg" /oldest
6 iferror= $error_no_file_found goto no_files
7 ftplogon "my_web_site"
8 sendfile %nextfile /archive
9
10 ***********************
11 * Update the RSS feed *
12 ***********************
13 SET filedatetime = %nextfiledatetime
14 DATETIMESUB filedatetime 5 /hour ;; Get time in GMT
15 ;; need to convert Sat Feb 17 11.00.22 2001 format to Mon, 21 Sep 2009 13:00:00 GMT format
16 SETLEFT DDD = filedatetime 3
17 SETMID MMM = filedatetime 3 5
18 SETMID dd = filedatetime 2 9
19 SETMID hh = filedatetime 2 12
20 SETMID mm = filedatetime 2 15
21 SETMID ss = filedatetime 2 18
22 SETRIGHT YYYY = filedatetime 4
23 SET day_date = DDD + ', ' + dd + ' '
24 SET month_year = MMM + ' ' + YYYY + ' '
25 SET hhmm = hh + ':' + mm + ':'
26 SET ssGMT = ss + ' GMT'
27 SET timestamp = day_date + month_year + hhmm + ssGMT
28
29 * Keep a local copy of the RSS feed without the last two lines
30 SET rss_file = "c:\rss\incomplete_rss_file.xml"
31 SET complete_rss_file = "c:\rss\rss.xml"
32 WRITEFILE rss_file '- ' /append
33 SET title = '
' + %nextfile + ' '
34 WRITEFILE rss_file title /append
35 SET description = '' + %nextfile + ' '
36 WRITEFILE rss_file description /append
37 SET pubdate = '' + timestamp + ' '
38 WRITEFILE rss_file pubdate /append
39 SET enclosure = '1" type="video/mpeg" />'
40 WRITEFILE rss_file enclosure /append
41 SET guid = 'http://mysite.com/' + %nextfile + ' '
42 WRITEFILE rss_file guid /append
43 WRITEFILE rss_file ' ' /append
44
45 COPY rss_file complete_rss_file
46 WRITEFILE complete_rss_file '' /append
47 WRITEFILE complete_rss_file '' /append
48 * Upload the updated RSS file *
49 SENDFILE complete_rss_file
50
51 * loop back to the top to see if there are more files to send *
52 goto top
53
54 :no_files
55 ftplogoff
56 exit

