The rename procedure

Description

The rename procedure changes the name of a file.

Parameters

  1. The first parameter is a reference to the file variable that identifies the file to be renamed. The name of the file variable is the name of the file to be renamed.
  2. The second parameter is an expression of string type or char type, and is the new name of the file.

Example

   (* This program renames a single file *)
   program rename;
   var
      f : text;

      procedure syntax;
      begin
         writeln('Renames a file');
         writeln('Syntax: ivm rename old new');
         writeln('  renames a file named ''old'' to ''new''');
         exitcode := 1;
        halt
      end;

   begin
      if paramcount <> 2 then
         syntax;
      assign(f, paramstr(1)); //Specify which file you want to rename
      rename(f, paramstr(2))  //Change the name of the file
   end.

Portability

Operating Systems: All
Standard Pascal: No