home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ckscripts / ftprename < prev    next >
Text File  |  2020-01-01  |  2KB  |  44 lines

  1. ; Kermit FTP script to add ".old" suffix to all files in a server directory.
  2. ; Requires C-Kermit 8.0 (Unix) or Kermit 95 2.0 (Windows):
  3. ; http://www.columbia.edu/kermit/
  4. ;
  5. ; F. da Cruz, Columbia University, July 2002
  6. ;
  7. ; Change these as appropriate or convert them to command-line parameters.
  8. ; See: http://www.columbia.edu/kermit/ckscripts.html for an explanation.
  9. ;
  10. define user olga                                ; Username
  11. define host ftp.xyzcorp.com                     ; Hostname
  12. define dir  invoices                            ; Remote directory name
  13. define rfs  *                                   ; Remote file specification
  14. define tmp  filelist                            ; Local temp file name
  15.  
  16. ; The rest of the script doesn't need to be changed
  17.  
  18. ftp \m(host) /user:\m(user)                     ; Open the connection
  19. if fail stop 1 ftp open \m(host) failed         ; Check for failure
  20. ftp cd \m(dir)                                  ; CD to remote directory
  21. if fail stop 1 ftp cd \m(dir) failed            ; Check for failure
  22. ftp mget /namelist:\m(tmp) \m(rfs)              ; Get list of filenames
  23. if fail stop 1 ftp mget /namelist failed        ; Check for failure
  24. fopen /read \%c \m(tmp)                         ; Open the namelist file
  25. if fail stop 1 Open \m(tmp) failed: \f_errmsg() ; Check for failure
  26.  
  27. .\%n = 0                                        ; Initialize file counter
  28. set flag off                                    ; Error indication
  29. while not flag {                                ; Loop through files
  30.     fread \%c filename                          ; Read next filename
  31.     if fail break                               ; Failure is EOF
  32.     increment \%n                               ; Count the file
  33.     echo \%n. \m(filename)                      ; Give feedback
  34.     ftp rename \m(filename) \m(filename).old    ; Rename this file
  35.     if fail set flag on                         ; Check for failure
  36. }
  37. ftp dir                                         ; Done - Show remote files
  38. ftp bye                                         ; Disconnect from server
  39.  
  40. if flag stop 1 ftp rename failed: \m(filename)  ; Report any failure
  41. echo Files renamed: \%n                         ; Or report success
  42. end
  43.