The rename procedure


The rename procedure changes the name of a file.


  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.


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

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

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


Operating Systems: All
Standard Pascal: No