Hello everyone :)
I am trying to write VB code for reading filenames and file property values in a specific directory.
For example, I have a directory called C:/Bears and in that directory are three files: Brown Bears.txt, Black Bears.txt, and Orange Bears.txt. Each of these files have text descriptions in both the Title property field and the Comments property field of the each file (when you right click the file and select Properties, and then select the Summary tab and in there are many fields, two of wich are Title and Comments). I want to be able to loop through every file in this folder and do the following:
1) read the color of each bear from the filename itself (Brown, Black, and Orange), not the whole filename, into variables,
2) read the text from the Title property field of each file into variables, and
3) read the text from the Comments property field of each file into a variable.
Any suggestions?
Thanks!
Wayne.
4 20699
Hello everyone :)
I am trying to write VB code for reading filenames and file property values in a specific directory.
For example, I have a directory called C:/Bears and in that directory are three files: Brown Bears.txt, Black Bears.txt, and Orange Bears.txt. Each of these files have text descriptions in both the Title property field and the Comments property field of the each file (when you right click the file and select Properties, and then select the Summary tab and in there are many fields, two of wich are Title and Comments). I want to be able to loop through every file in this folder and do the following:
1) read the color of each bear from the filename itself (Brown, Black, and Orange), not the whole filename, into variables,
2) read the text from the Title property field of each file into variables, and
3) read the text from the Comments property field of each file into a variable.
Any suggestions?
Thanks!
Wayne.
What VB are you using? From previous posts, I'm assuming VBA. You can open the text file via Word and use the BuiltInDocumentProperties method of the document. Other Office apps have the same method. HTH --Sam
Hi, thanks for the reply.
I'm using Visual Basic 6.0.
I also need to read file properties of jpeg and other image files as well. Does this work with them too?
Thanks,
Wayne.
What VB are you using? From previous posts, I'm assuming VBA. You can open the text file via Word and use the BuiltInDocumentProperties method of the document. Other Office apps have the same method. HTH --Sam
> I'm using Visual Basic 6.0.
Then just add a reference to Microsoft Word Object Library and open the file
>I also need to read file properties of jpeg and other image files as well. Does this work with them too?
They don't have a Summary tab, so the DocProperties will be blank. Word may complain when opening so I would set DisplayAlerts = False
But, with a little more searching, I found that Microsoft has a utility to help you read them w/o opening the files. See http://support.microsoft.com/?kbid=224351. Don't wory about the .Net stuff, it works in VB6 and the download comes with a VB6 example. Something like: - Dim oFilePropReader As New DSOleFile.PropertyReader
-
Dim oDocProp As DSOleFile.DocumentProperties
-
Dim sFile As String
-
sFile = "C:\MyFolder\MyDocument.doc"
-
Set oDocProp = oFilePropReader.GetDocumentProperties(sFile)
-
MsgBox oDocProp.Author
-
Set oDocProp = Nothing
-
Set oFilePropReader = Nothing
Thanks for that, Sammy. This looks like another entry for the Tips & Tricks, when I have time.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: hokiegal99 |
last post by:
This script works as I expect, except for the last section. I want the
last section to actually remove all spaces from the front and/or end of
filenames. For example, a file that was named " test ...
|
by: Joel Goldstick |
last post by:
I wanted to write a simple page to let me choose a directory and then list
the files in it. The end goal was to make an easy way to copy all the
file names in a directory. I tested with Opera7,...
|
by: Tim |
last post by:
Does anyone know a way to read the filenames from a given directory in
C in a Solaris environment?
I did this, but it seems goofy:
sprintf(t, "ls *.csv > filenames.txt");
system(t);
fptr =...
|
by: rbutch |
last post by:
guys, i need a little help with this.
this is working (well sort of)
i get the info, but it's not moving to a new line as it iterates thru the array
and all of the fields are like ONE HUGE LONG...
|
by: I_AM_DON_AND_YOU? |
last post by:
I have a small VB.Net Solution. The solution has filename LABELMAKER.SLN and
the the project has filename LABELMAKER.VBPROJ. There is another file
LABELMAKER.VBPROJ.USER. All these are in a...
|
by: rtilley |
last post by:
# Spaces are present before and after the XXX
filename = ' XXX '
new_filename = filename.strip()
if new_filename != filename:
print filename
Macs allow these spaces in file and folder...
|
by: Taras_96 |
last post by:
Hi everyone,
Firstly, I would like to know if you can open chinese filenames under
win2000 using PHP 5.0? I have a file named ä¸å›½.php, and try to open it
using
fopen(‘ä¸å›½.php','r');....
|
by: Joakim Hove |
last post by:
Hello,
I am reading a filename from the user - the loop is typically like
this:
1. Read a directory from the user.
2. Read several filenames from the user.
The filenames read in 2. above...
|
by: Manogna |
last post by:
hi! all,
in a directory nearly 10 zipped file are available.
totally the size of the all files is nearly 15GB.
i have to retrive the line which dont have the text "ORA" from each file...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |