Erlang - rename



This method is used to rename an existing file.

Syntax

rename(oldfilename,newfilename)

Parameters

  • oldfilename − This is the original file name.

  • newfilename − This is the name to which the file should be renamed to.

Return Value

A status on the rename operation. If this is successful, an {Ok} message will be displayed.

For example

-module(helloworld). 
-export([start/0]). 

start() ->
   io:fwrite("~p~n",[file:rename("Newfile.txt","Renamedfile.txt")]).

Output

The file Newfile.txt will be renamed to Renamedfile.txt.

erlang_file_input_output.htm
Advertisements