Perl-Python-a-Day: split a file full path

matteo d'addio 81 m_a_t_e_81 at yahoo.it
Mon Oct 17 16:36:31 EDT 2005


Hello, I'm a cs student from Milano (Italy).
I don't use scsh fequently but this should work:

(open srfi-11  ;let-values
      srfi-28) ;format

(define my-path "/Users/t/web/perl-python/I_Love_You.html")

(let-values (((dir-name
               file-base-name
               file-extension) (parse-file-name my-path)))

  (format "~a~%" dir-name)         ;/Users/t/web/perl-python/
  (format "~a~%" file-base-name)   ;I_Love_You
  (format "~a~%" file-extension))  ;.html

You can find more useful function here (scsh reference manual):
http://www.scsh.net/docu/html/man-Z-H-6.html#node_sec_5.1

matteo




More information about the Python-list mailing list