Rebol 编程/重命名
外观
< 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
]