Move or rename files in a report

I have a report, “read files” that is reading file(s) in the c:\import\ folder

abc.txt

cde.txt etc

After processing the files I need to move or rename them.

From the threads I have read, it seems that I would have to run another report, “rename files” on exit that will rename all the files.

It does not seem possible to do the rename (or move) from the “readfiles” report as it still has the file open until it exits.

Any ideas on how to do this without the use of “rename files” report?

My quick and dirty solution is to RUN the processing report and then RENAME the files.

- OnPreDataItem()

RESET;

SETRANGE(“Is a file”,TRUE);

SETFILTER(Path,TEMPORARYPATH);

FINDFIRST;

SETFILTER(Path,‘c:\import’);

SETFILTER(Name,’@*.txt’);

- OnAfterGetRecord()

FileName := Path + Name;

FileName2 := FileName + ‘.FIN’;

REPORT.RUN(50006);

FILE.RENAME(FileName,FileName2);

You can call the CLOSE method on your File variable to release the handle on it. Then you can rename it in the same report.

You can also use an automation type: ‘Windows Script Host Object Model’.FileSystemObject

This automation has a ‘MoveFile’ method. All you need to do is specify the source and target file names and it will take care of everything. You’ll still need to CLOSE the file first, but at least you won’t have to deal with any confirmation messages.