fbungarz wrote: 10 Dec 18 23:33Out of 38 image files, only 24 are imported, 14 skipped.
Did you check that numbers in the series didn't already exist on the hard drive?
I just checked the PSU code and the script code and I can't think of any reason why this wouldn't work. And as mentioned, it works flawless here. So something must be different. Already existing files in the target folder in the range could be an explanation.
Anyway, here's a version for your rename script that has locking hard coded in the script. I don't expect this to make any difference since PSU already does name rule parsing inside a lock of the import session...and so this is a wild shot. If this too doesn't work for you then I can only imagine that the files already exist in your target folder from a previous download. Or that somehow you're not using the download profile that you expect to be using.
Code: Select all
// - This script is designed to be used with the downloader pre-script
// "Download by Prefix", as it manages some of the registry keys used
// by this script.
// JAG, 16-Apr-2007
// HVZ, 23-Jun-2016 (converted to Photo Supreme)
// HVZ, 06-Dec-2018 (made script independent of the sequence as with multithreading, the sequence is not predictable)
// HVZ, 11-Dec-2018 (added critical section)
const
cScriptName = 'DownloadByPrefixList';
var
highestNumber, lastNumber: Integer;
prefix: WideString;
AStackName: WideString;
AFiles: TTntStringList;
ALock: TxomCriticalSection;
idx: Integer;
begin
ALock := TxomCriticalSection(StrToPtrInt(Nvl(PopFromStack(cScriptName), '0')));
if ALock = nil then
begin
ALock := TxomCriticalSection.Create(cScriptName);
PushToStack(cScriptName, PtrIntToStr(ALock));
end;
ALock.Acquire;
try
prefix := ReadFromRegistry ('dlByPrefixCurrent', 'prefix', '');
if (prefix = '') then prefix := 'UNKNOWN_';
highestNumber := ReadFromRegistry ('dlByPrefixCurrent', 'value', 0);
AStackName := cScriptName + prefix;
AFiles := TTntStringList(StrToPtrInt(Nvl(PopFromStack(AStackName), '0')));
if AFiles = nil then
begin
AFiles := TTntStringList.Create;
PushToStack(AStackName, PtrIntToStr(AFiles));
end;
if VarToStr(Nvl(PopFromStack(AStackName + 'session'), 0)) <> Session.GUID then
begin
AFiles.Clear;
PushToStack(AStackName + 'session', Session.GUID);
end;
idx := AFiles.IndexOf('%FileName');
if idx = -1 then
begin
lastNumber := highestNumber + 1;
AFiles.AddObject('%FileName', lastNumber); // maintain the number used for this filename
end
else
begin
// reuse the same number for existing files (e.g. TEST.JPG and TEST.NEF)
lastNumber := AFiles.Objects[idx];
end;
if lastNumber > highestNumber then
begin
WriteToRegistry ('dlByPrefixLastVals', prefix, lastNumber);
WriteToRegistry ('dlByPrefixCurrent', 'value', lastNumber);
end
// return our newly constructed filename
result := prefix + AddLeadingChars (IntToStr(lastNumber), '0', 4, False);
finally
ALock.Release;
end;
end;