You are not logged in.
Pages: 1
Hi,
In a folder there are one src and one txt files. How can I rename the txt file so that it copies src file name?
Before renaming: today.src and tomorrow.txt
After renaming: today.src and today.txt
Offline
You'll need to use the Pascal Script rule for this.
This script will find the first file matching the specified mask (MASTER_FILE_MASK) located in the same directory, and will use its base name as the new name for the file in the renaming list.
const
MASTER_FILE_MASK = '*.src';
function FindFirstFile(const Folder, FileMask: WideString): WideString;
var
Files: TWideStringArray;
begin
Result := '';
SetLength(Files, 0);
WideScanDirForFiles(Folder, Files, False, False, False, FileMask);
if Length(Files) > 0 then
Result := Files[0];
end;
var
MasterFile: WideString;
begin
MasterFile := FindFirstFile(WideExtractFileDir(FilePath), MASTER_FILE_MASK);
if Length(MasterFile) > 0 then
FileName := WideExtractBaseName(MasterFile) + WideExtractFileExt(FilePath);
end.P.S. This script now has a permanent place in the Pascal Script Library.
Offline
Pages: 1