Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching directory for images 2

Status
Not open for further replies.

Jonah86

Programmer
Dec 11, 2003
152
US
I need to be able to read in all of the bmp files in a directory, preferably as strings, and be able to parse the filesnames somehow. My higher-up's have decided to scan in our work orders and name the files something like "account#-date.bmp", and I need to be able to find the files based on the account#, and then sort those based on the date. Apparantly a database setup would be far too easy, and they hate making things easy on me.

Anyone have any ideas on how I could go about this? Please?
 
The findfirst and findnext functions may be what you are looking for, with these you can search in folders for files whoes names match specified patterns and build up a list.
using wild cards e.g
fullpath/*.bmp
Usage is well documented in the help files, and you should be able to find several examples in this forum
I assume that you can do what you want simply from the filenames, it should not be nessacary to 'read in' the entire file.


Steve
Be excellent to each other and Party on!
 
The problem is that I have to be able to the account# and date parts of the filename seperately. I need to be able to put in an account number and come up with a list of all the images for that number. I'm not sure how this would work using the method you describe.

I'm sure there's something I'm not seeing here.
 
is the dash '-' actually present in the filenames?

With Findfirst/next you should be able to search for NNNN*.bmp where NNNN is your account number, and get a list of file with that account number but any dates.
I dont have time to post you an example tonight im afraid.


Steve
Ive not been well!
 
Ah, I think I see. That would work out perfectly. I'll see if I can get that working. Thanks.
 
Got that to work pretty much how I want it. Only problem with this is that I can't use the dates to filter out older work orders.

Yes, the dash will be in the filename, probably multiple dashes for the date. I'm not sure yet how they're going to name the files exactly.

Is there any to tell Delphi to get the characters after the first dash? So that I could then use the date for searching and sorting.

Thanks for your help, that method works very well aside from my one little issue.
 
You could use Pos for that, Pos(Substring,string);
Where Substring would be the dash and string the filename.
This way you get the position of the first dash Pos encounters, you could for example do something like this:
Code:
Delete(MyFileName,1,Pos('-',MyFileName);

Causing the junk infront of the relevent data to be deleted from the string, you might wanna do that in a different variable from the original though.

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
Great Delphi Websites faq102-5352
 
Oh that's perfect! Is there any way to delete something AFTER a certain character, like the period in the extention? I couldn't figure it out in the Delphi help.

Thanks so much!
 
Nevermind, figured it out. Thanks again for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top