Results 1 to 8 of 8

Thread: Categorize files that are in a single folder

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Categorize files that are in a single folder

    Is there a way to categorize files that are located within a single folder ?
    I am considering using the Comments field in the file's attributes to store the category(s)
    Say there is a single folder in the C drive, and I display all it's file names in a listbox.
    The files mainly would be .msg .docx .xlsx .pdf
    Sometimes the user wishes to show all the files in the listbox.
    Some other times they wish to apply a filter to the list in the listbox.
    The filter would NOT be based on the extension, instead it would be based on some categories.
    The categories are related to their business, but let us say they are these -
    CAT1 CAT2 CAT3 CAT4 CAT5 CAT6 CAT7
    They wish to mark some of the files with a category, and sometimes a file would have multiple categories.
    They do not wish to change the File names.
    Can the categories be stored in the file attributes (perhaps in the Comments field)
    One file might have just Cat2
    Another file might have Cat2 and Cat3 and Cat6 (stored thus in the comments field "Cat2 Cat3 Cat6")
    When they apply the filter (say Cat2), only files with Cat2 in the comments field, would show in the listbox.
    If they apply a filter of Cat 6, only one file appears in the Listbox
    If they apply a filter of Cat 2, both files will appear in the Listbox

    Can the Comments field be used reliably, in that manner ?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Categorize files that are in a single folder

    it would probably be better to put all the files in the folder into a data base, with the categories in a field (or fields) for easy searching

    if required files could be added to, or removed from the database by monitoring the folder, else manually, or just check all the files still exist in a loop
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Categorize files that are in a single folder

    Most file formats do not allow for metadata like "Comments."

    Those that do store it in different ways, and the Explorer Shell gets at them via registered Shell Extension Handler DLLs. Windows comes with a set of these, but for many file kinds the associated software installs such a Handler.

    So if you had some FubbView Presentation documents but you didn't have FubbView Presenter installed you'd have no access to any document properties contained within such files.

    And for example plain Text files have no such metadata at all.

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Categorize files that are in a single folder

    Maybe see Creating Shell Extension Handlers if this is a novel concept to you.

    Normally this is done by a software vendor supporting their own custom document formats.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: Categorize files that are in a single folder

    Some of you may be interested in this, and perhaps can help me translate it (Access VBA to VB6) -
    http://www.everythingaccess.com/tuto...erating-System

    I tried using MS's example -
    https://support.microsoft.com/en-au/...fice-installed

    I installed the VB6 example and tried it in XP Pro 32bit.
    It ran fine but gave an error when I attempted to read a PDF file.
    Many of the files will be PDF, so that rules that out.
    I came across an Access program that reckons it is better than DSOfile.dll, and it is -
    http://www.everythingaccess.com/tuto...erating-System
    The author mentions this -
    "a convenient solution to including native machine code into a small VBA module which doesn't require any external references. In effect, it is like having a small DLL file contained completely within your VBA project"
    "I have done the same here in that the sample database file contains native machine code inside a VBA code module in order to avoid you needing to distribute an extra DLL or typelibrary file with your application should you choose to use this code"

    I have downloaded the Access DB, and ran it.
    Sure enough, it lists all sorts of goodies, including the Tag and Comments fields that I hope to use.
    I have only tested in XP (where my VB6 IDE resides), but hopefully the fields I am interested in will also be shown in W7/W10.
    The code apparently can be easily(for some people) tweaked to do updates as well.
    My problem is I have never developed in Access, and I suspect some of the logic is squirreled away in Properties/events of Controls/Objects.
    Are there any members who know both Access programming and VB6, that are interested in helping convert it to VB6 ?
    I reckon it will be Codebank worthy, once it can work from VB6 project.

    Thanks,
    Rob
    PS The author (Wayne Phillips), has a link for Donations (I donated)

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Categorize files that are in a single folder

    The "DSO OLE Document Properties Reader 2.1" has a few quirks.

    One of these is that for file types that don't have a Shell filter installed, or one that doesn't support a common Office document DocumentProperty (for example Comments) it will stuff values you assign into alternate data streams.

    For example, I "stuffed" two files in such a manner using the dsofile.dll:

    Code:
    D:\altered files>dir /r
     Volume in drive D is Data Large
     Volume Serial Number is C6F6-C37F
    
     Directory of D:\altered files
    
    03/20/2017  01:19 PM    <DIR>          .
    03/20/2017  01:19 PM    <DIR>          ..
    03/20/2017  01:02 PM            20,597 small.pdf
                                        88 small.pdf:DocumentSummaryInformation:$DATA
                                       128 small.pdf:SummaryInformation:$DATA
                                         0 small.pdf:{4c8cc155-6c1e-11d1-8e41-00c04fb9386d}:$DATA
    03/20/2017  01:03 PM                 0 testfile.txt
                                        88 testfile.txt:DocumentSummaryInformation:$DATA
                                       128 testfile.txt:SummaryInformation:$DATA
                                         0 testfile.txt:{4c8cc155-6c1e-11d1-8e41-00c04fb9386d}:$DATA
                   2 File(s)         20,597 bytes
                   2 Dir(s)  686,467,866,624 bytes free
    
    D:\altered files>
    You can see the extra streams it added.


    This is how such things were handled back in olden times, but the Explorer Shell no longer supports them stored that way:

    What happened to the Summary information created on Windows 2000 and Windows XP?

    In Windows 2000 and Windows XP, you could add Summary information on the Details property page to files of all types. Text files, image files, some crazy file your grandmother sent you in a file format you don't know how to open. If Windows supports storing the Summary information in the file itself (for example, in EXIF tags or in Structure Storage properties), then the information gets stored there. Otherwise, Windows stashes the information in an alternate data stream. Windows Vista dropped support for storing Summary information in alternate data streams. What happened?

    Support for storing Summary information in an alternate data stream was dropped in Windows Vista because alternate data streams were found to be too fragile. If you back up the file to a CD-ROM or email it to a friend or copy it to a thumb drive or upload it to a Web site or store it in a ZIP file, the alternate data stream ends up lost. It was determined that it was better simple not to allow users to create data that was so easy to destroy accidentally.
    Sure enough, the Explorer Shell ExtendedProperty collection never reflects the values stuffed in that way anymore. You need Shell filters installed for each type of file you want to do this to, and the filters must support all of the ExtendedProperty settings you want to twiddle.

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Categorize files that are in a single folder

    I cringe to think of what anti-malware scanners would make of that guy's attempts to embed code within an MS Access MDB, ACCDB, etc. We also have no clue what he's doing but it is probably either copying what dsofile.dll does (if he isn't actually using some version of it itself) or else getting read-only access via Shell Automation objects.

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Categorize files that are in a single folder

    What I have been calling "filters" vary by OS.

    Prior to the LongHorn era that began with Windows Vista, XP and earlier had something called Column Handlers. See Creating Column Handlers.

    Of course XP is dead now, and in a modern OS we have Property Handlers. See Understanding Property Handlers.

    These are provided by software vendors. MS Office supplies some for Office document types, Windows Media Player supplies a few, etc. Installing another software product might add more and in some cases even replace the ones that a previous software install put in place.

    Simple file types like text files don't usually have one at all. Something like PDF files might have one or another one (Acrobat Reader might install one, and installing a recent MS Word version might replace that by another). Even installing a new version of a product might well replace the filter/handler.

    So one day PDF files might have a "Comments" summary property and the next day it might not work anymore because you uninstalled the Adobe product.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width