Rebol 程式設計/重新命名
外觀
RENAME old new
將檔案重新命名為新名稱。
RENAME 是一個函式值。
- old -- 舊檔案的路徑(型別:檔案 URL)
- new -- 新名稱(不是路徑)(型別:檔案 URL 字串)
- 捕獲
rename: func [
"Renames a file to a new name."
[catch]
old [file! url!] "path to the old file"
new [file! url! string!] "new name (not a path)"
/local p dir blk
][
dir: open first p: split-path clean-path old
blk: copy dir
either not none? blk: find blk second p [
throw-on-error [change skip dir ((index? blk) - 1) new]
] [
throw make error! reduce ['access 'no-rename old]
]
close dir
]