Name...As and Rename...As Commands

Purpose

Renames a file.

Syntax

Name old$ As new$

Rename old$ As new$

old$, new$: sexp; old and new file names

Description

Name...As is synonymous with Rename...As, and both rename the specified file.

Example

Dim old$ = "C:\TEST.DAT", new$ = "C:\TEST.TXT"

// Create "c:\test.dat"

BSave old$, 100000, 100

Print "Directory showing "; old$

Dir "c:\*.*"

Print

// Rename "c:\test.dat" as "c:\test.txt"

If Exist(new$) Then Kill new$ (* If Test.txt exists, Name will cause an error *)

Name old$ As new$

Print "Directory showing "; new$

Dir "c:\*.*"

Print

// Change "c:\test.txt" back to "c:\test.date"

If Exist(old$) Then Kill old$ (* If Test.txt exists, Rename will cause an error *)

Rename new$ As old$

Print "Directory showing "; old$

Dir "c:\*.*"

Remarks

See Also

CopyFile, FileCopy.

{Created by Sjouke Hamstra; Last updated: 11/07/2023 by James Gaite}