Folder rename using PascalScript

English Support for Syncovery on Windows.
Post Reply
thx1200
Posts: 1
Joined: Wed Jun 22, 2022 2:40 pm

Folder rename using PascalScript

Post by thx1200 »

For OneDrive/SharePoint, folders with the name "_vti" are not allowed due to the history of Front Page Extensions and whatnot. Anyway, I'm backing up a bunch of old stuff to OneDrive and it won't sync those folders. No problem, I see PascalScript seems to be able to handle this. I wrote a simple script, but I am not well versed in PascalScript and I'm getting a type mismatch error. I tried a lot of different things, like utf8encode/decode and stuff, no luck. Can somebody help?

function OnReplaceFilenameLeftToRight(const FileName: UnicodeString;
const isFolder: Boolean):UnicodeString;
begin
if isFolder and FileName = '_vti' then
Result := 'RENAMED_vti'
else begin
Result := FileName
end;
end;

function OnReplaceFilenameRightToLeft(const FileName: UnicodeString;
const isFolder: Boolean):UnicodeString;
begin
if isFolder and FileName = 'RENAMED_vti' then
Result := '_vti'
else begin
Result := FileName
end;
end;

tobias
Posts: 1023
Joined: Tue Mar 31, 2020 7:37 pm

Re: Folder rename using PascalScript

Post by tobias »

Hi,
all you need is some parentheses:

Code: Select all

function OnReplaceFilenameLeftToRight(const FileName: UnicodeString;
const isFolder: Boolean):UnicodeString;
begin
if isFolder and (FileName = '_vti') then
Result := 'RENAMED_vti'
else begin
Result := FileName
end;
end;

function OnReplaceFilenameRightToLeft(const FileName: UnicodeString;
const isFolder: Boolean):UnicodeString;
begin
if isFolder and (FileName = 'RENAMED_vti') then
Result := '_vti'
else begin
Result := FileName
end;
end;

Post Reply