WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Error Codes

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Error 1015: Filerename failed

Keywords:  1015 filerename

Question:

Exactly what conditions cause the error 1015: FileRename?

Answer:

The following script checks the existence of source and target files.

You'll get the "1015 File Rename Failed" error if the source file does not exist, or if the target file already exists. This code checks that the source file exists, and that the target file is deleted if it exists, then renames the file.

src = "C:\temp\source.txt"
trg = "C:\temp\target.txt"
fesource=FileExist(src)
If fesource==1 ;Make sure source file exists
	Message("YEP",StrCat(src," exists"))
	fetarget=FileExist(trg)
	If fetarget==1 ;Delete target if it exists
		Message("YEP",StrCat(trg," exists")) 
		FileAttrSet(trg,"rash") ;Remove read-only attribute on target, so it can be deleted
		Errormode(@Off)
		ret = FileDelete(trg) ;Delete target file 
		Errormode(@on)
		If ret==0
			Message("Opps File was","NOT DELETED")
			exit
		Else
			Message("File was","DELETED")
			fn=FileRename(src,trg) ;Rename file
			message("Finished","File was renamed from source.txt to target.txt")
		Endif
	Endif
Endif

Article ID:   W12933
Filename:   1015 FileRename Failed.txt
File Created: 2002:04:03:10:27:14
Last Updated: 2002:04:03:10:27:14