Page 1 of 1
Check file availability
Posted: 2016-03-18 06:25:59
by usefamin
Hello everyone
I was wondering if there's a script that checks the existence of the files in the folder. By which i mean, a script that simply checks the file is still available in the folder or not.
I move files all the time several times a day and the cataloging becomes obsolete without this feature to me (it's actually why I need a tool to keep track of which files are where now).
Would appreciate any help

Posted: 2016-03-18 08:58:18
by antp
There is a FileExists function which takes in parameter a file path (string) and returns true or false depending if it exists or not.
So for example if your files paths are in the appropriate field, the following script run on the list will pop a message when a file does not exist:
Code: Select all
program NewScript;
var
s: String;
begin
s := GetField(fieldFilePath);
if FileExists(s) = False then
begin
ShowMessage('File does not exist: ' + s);
end;
end.
Posted: 2016-03-19 03:51:09
by usefamin
Fantastic. Thank you very much.
I don't suppose there's a way to generate a txt log of those files while we're at it? :P
Posted: 2016-03-26 20:53:03
by antp
You mean instead of displaying the message?
Yes that should be possible, by writing a file to a location like the "Find Duplicate" script does
Posted: 2016-03-26 22:23:49
by usefamin
Yes exactly.
I have very limited knowledge when it comes to this and I'm trying to copy the ResultPath :=
But it gives me a unknown identifier error.
Help please? :S
Posted: 2016-03-27 09:31:09
by antp
What error do you have for which code ?
Re: Check file availability
Posted: 2018-05-28 10:26:44
by usefamin
So sorry to never have replied, my laptop was stolen and now two years later I'm stuck with the same issue.
I think I'm just really unable to comprehend the simple terms and strings.
How do I add a string to to the existing script to make it generate a txt file?
Thank you in advance for any help
Re: Check file availability
Posted: 2018-05-28 18:42:51
by antp
Something like this should do it:
Code: Select all
program CheckFiles;
uses
StringUtils1;
var
MovList: TStringList;
s, CurFile, CurMovie: string;
ResultPath: string;
begin
if ResultPath = '' then
begin
ResultPath := 'c:\list.txt';
Input('Check files', 'Store results to:', ResultPath);
end;
if ResultPath = '' then
begin
Error;
end;
CurMovie := GetField(fieldOriginalTitle);
CurFile := GetField(fieldFilePath);
s := CurMovie + #9 + CurTitle + #9;
if FileExists(CurFile) then
s := s + "Yes"
else
s := s + "No";
MovList.Add(s);
MovList.SaveToFile(ResultPath);
end.
(not tested)
It is not very efficient because it rewrites the list on each movie, but I don't really know the functions that soulsnake added in 4.x versions that allow to make it otherwise.