Andrew Martin wrote:

> Anyone got a recursive directory deleter written?
>

Its part of my chainsaw collection.  --Ryan

erase: function [
  "Recursively erase a directory structure, including files."
  target [file!] "Directory to delete."
] [
  dir-list
] [
  either dir? target [
    dir-list: read target
    foreach filename dir-list [
      either dir? rejoin [target filename ] [
        erase rejoin [target filename ]
      ] [
        delete rejoin [target filename ]
      ]
    ]
    delete target
  ] [
    delete target
  ]
]



file-copy: function [
  "Recursively copy files."
  source [file!] "Source directory or file."
  destination [file!] "Destination directory or file."
] [
  dir-list
] [
  either dir? source [
    dir-list: read source
    foreach filename dir-list [
      either dir? rejoin [source filename ] [
        if not exists? rejoin [destination filename ] [ make-dir rejoin
[destination filename ] ]
        file-copy rejoin [source filename ] rejoin [destination filename
]
      ] [
        file-copy rejoin [source filename ] destination
      ]
    ]
  ] [
    either dir? destination [
      if not exists? destination [ make-dir destination ]
      write/binary rejoin [ destination any [ find/last/tail source "/"
"" ] ]
        read/binary source
    ] [
      write/binary destination read/binary source
    ]
  ]
]


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to