Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have made a copy of a directory on the server containing about 45.000 files, most in jpg format, some different and I want to run a script to loop over all these and just record the filename for once - I will go from there.
For some reason, the code I have doesn't work - it looped over all the files, I could watch it in the progress_window - but I see only BLANKs in a listbox.
The code is like this
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Zunächst laden wir eine kleine Dummy-Tabelle
Dateinamen:
FIRST 1 LOAD
' ' as Dateiname_alt
RESIDENT Fin_Bew
;
DIRECTORY 'C:\Users\friedrich.hofmann\Documents\QS_IdentBilder\Sicherungskopien_20160126\';
FOR EACH File in FileList('*')
Concatenate (Dateinamen) FIRST 1 LOAD '$(file)' as Dateiname_alt AutoGenerate 1;
NEXT File
STORE Dateinamen INTO 'C:\Users\friedrich.hofmann\Documents\QS_IdentBilder\Metadaten\Gesamtliste\Alle_alle.qvd';
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
So I loaded a small dummy_file to concatenate to in each iteration of the loop - so I have one record too much, I can get rid of that lateron - and then I start the loop and for every file I encounter, I just want to load the file_name_and_path.
Can anyone help me find out why this isn't working?
Thanks a lot!
Best regards,
DataNibbler
No need to load from the file itself, just use autogenerate 1.
edit:
And if you need to load from the file (you don't in your scenario shown), use
LOAD '$(File)' as FileName
FROM [$(File)];
For each has "File" and you are saving "file". Remember that QV field names are case sensitive.
Hi Jonathan,
that sounds like a sound reason. I will try. Too bad that I cannot just cancel the process after 10 or 50 records to see if it's working ...
That seems to work - but I just got an error_message about some file that has a >>(2)<< in the filename. Guess it's a copy of some other file.
Can I like put the name I want to load in square brackets or something so that it's loaded no matter what characters it has?
I guess deleting that particular file would also do the trick, but "manually" parsing a heap of 45.000 files and finding that one is simply impossible ...
Well, I have found and deleted this one, but there appear to be others with brackets in the filename where there is actual info inside the brackets, so I cannot delete them.
How can I pack the filename now so that it will still be loaded?
Thanks a lot!
Hi DataNibbler,
you could simply adjust the filename with keepchar() or purgechar().
- Marcus
Hi Marcus,
but I do not want to adjust anything - I just want to assemble a list of all the filenames such as they are because if I adapt anything, then the command-line-command to move any files must necessarily fail because the filenames I have in the list are not the real ones ...
P.S.: Well, if I can keep the process in control - would it help to replace brackets by another symbol? I cannot tell because I do not quite know why the LOAD fails.
I can't reproduce your issue:
For each File in FileList('E:\Users\Stefan\Downloads\*')
LOAD '$(File)' as FileName
AutoGenerate 1;
Next File
Runs fine, even with filenames containing (..).
What error message did you get?
Hi swuehl,
I got an "error reading file ..."
In the first instance, the filename was something with just the (2) in the filename, just before the ending >>.ppt<<.
Now I have the same issue with a filename where there is actual additional info, but with a (200mm).ppt, so again it's just in front of the ending.
Hi Stefan,
he meant square-brakets. Maybe additionally single-quotes could be helpful, like:
LOAD '"$(File)"' as FileName
- Marcus