Pascal Script Help

English Support for Syncovery on Windows.
Post Reply
mike.macdonald
Posts: 1
Joined: Wed May 11, 2022 8:02 pm

Pascal Script Help

Post by mike.macdonald »

Hello there,

I'm a new Syncovery user and was very much hoping somebody on this forum could help me out the following requirement:

- I have a single standard job that copies .csv files L-R.
- The right-hand side is a SharePoint document library - works as expected.
- Ideally I need to rename the .csv files on the right-hand side post copy, by removing the date stamp portion of the filename, regardless of the daily date stamp changes.

Filename Example:
FilenameA-11-05-2022.csv renamed to FilenameA.csv
FilenameB-11-05-2022.csv renamed to FilenameB.csv
FilenameC-11-05-2022.csv renamed to FilenameC.csv

Can this be achieved using Syncovery's Pascal scripting support and if so, would any kind souls out there be generous enough with their time to either guide me on the topic, or perhaps provide an example script that I could modify and learn from?

Thanks very much for the time you've spent reading this post.

All the best,
M

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

Re: Pascal Script Help

Post by tobias »

Hello,
here's a script that removes everything between a hyphen and the filename extension (and removes the hypen itself too).

If your filenames might contain hyphens other than just before and within the timestamp, then the script would need to be modified. Just let me know.

Code: Select all

function OnReplaceFilenameLeftToRight(const FileName: UnicodeString;
        const isFolder: Boolean):UnicodeString;
var i:Integer;
begin
  if isFolder then
     Result:=FileName
  else begin
     i:=Pos('-',FileName);
     if i>0 then
        Result:=Copy(FileName,1,i-1)+ExtractFileExt(FileName)
     else
        Result:=FileName; 
     end;
  end;

Post Reply