PasteRack.org
Paste # 63997
2018-05-07 12:04:16

Forked from paste # 61373.

Fork as a new paste.

Paste viewed 51 times.


Embed:

Get First Level Folders

  1. #lang racket
  2.  
  3. ; Ich definiere eine Funktion:
  4. ; Alle Top-Level-Ordner des angegebenen Verzeichnisses
  5. ; als Liste von Dateisystemeinträgen zurückgeben
  6. (define (get-first-level-folders from-dir)
  7.   (parameterize ([current-directory from-dir])
  8.     (filter
  9.        directory-exists?
  10.        (directory-list from-dir))))
  11.  
  12. ; Ergebnis ausgeben mit mkdir davor zum "copypasten"
  13. (for-each
  14.    (lambda(entry)
  15.      (displayln (~a "mkdir \"" entry "\"")))
  16.    (get-first-level-folders "~"))

=>

directory-list: could not open directory

  path: /home/pasterack/racket68/share/pkgs/web-server-lib/w

eb-server/default-web-root/htdocs/~/~

  system error: No such file or directory; errno=2