Rename a file: Difference between revisions
Add J
m (→{{header|DOS Batch File}}: language tag) |
(Add J) |
||
Line 160:
renameFile "/input.txt" "/output.txt"
renameDirectory "/docs" "/mydocs"</lang>
=={{header|J}}==
J does not ship with a built-in utility for renaming files.
The following will work on Windows, Linux and Macs:
<lang j>frename=: 4 : 0
if. x -: y do. return. end.
if. IFUNIX do.
hostcmd=. [: 2!:0 '('"_ , ] , ' || true)'"_
hostcmd 'mv "',y,'" "',x,'"'
else.
'kernel32 MoveFileA i *c *c' 15!:0 y;x
end.
)
</lang>
Useage:
<lang j> 'output.txt' frename 'input.txt'
'/output.txt' frename '/input.txt'
'mydocs' frename 'docs'
'/mydocs' frename '/docs'
</lang>
=={{header|Java}}==
|