Results 1 to 10 of 10

Thread: Folder and file processing

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Folder and file processing

    I've never done any folder or file processing from VB - I'm kind of a database only person...

    I need to find the next .JPG file in some folder - it has lots of .JPG files, named like 0001.JPG, 0002.JPG and so on. I have the folder name in a string variable.

    After I do some processing in the VB side, I am going to want to copy this .JPG file to a sub-folder in the original folder (\ARCHIVE) and then also copy it to another sub-folder (\PROCESSED) - but in this sub-folder, it will be renamed as well. After these two successful copies I want to delete the original file.

    Any hints would be greatly appreciated. I've only ever used FSO for stuff like this and do not want to have to include another .DLL in my setup at this point!

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016

    Re: Folder and file processing

    i would use the native FileCopy() function.

    casey.

  3. #3

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Folder and file processing

    Thanks - that gets me the copy and then I can use KILL to delete the original...

    How do I find out what the next *.JPG file in a folder is - if I only know the folder name and not the actual .JPG name?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Folder and file processing

    Something like
    VB Code:
    1. Dim strLoadFiles As String
    2. 'once for all pdf files
    3. LoadFiles = Dir("c:\path\somefolder & "\*.pdf")
    4. Do While LoadFiles > ""
    5.    gsDocFileNameAndPath = "c:\path\somefolder "\" & LoadFiles
    6.    Call ProcessImportFiles(LoadFiles, frmMain)
    7.    LoadFiles = Dir
    8. Loop
    I had to do something along these lines a few months ago, only it was actually storeing .pdf files in an SQL database. I had no idea what their names were, only that they would have a .pdf extension, and be in a specific folder.

    ProcessImportFiles actually parses the entire pathfilename string into individual component for me to do cool stuff with later. This routine, however, will search an entire dir for whatever you want. In your case, change pdg to jpg (or whatever the extension is).

    Once you have done the deed, you can, as vbasicgirl suggests, use the tried and true FileCopy to pop them over to whereever, and rename them.

  5. #5

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Folder and file processing

    ok - found a DIR() function - me thinks that could be the final answer...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Folder and file processing

    I found it a minute before you did...

  7. #7

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Folder and file processing

    Hack - thanks

    But more important then how to do it is the fact that this method is used by others - I would hate to do something that was frowned upon...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Folder and file processing

    Quote Originally Posted by szlamany
    Hack - thanks

    But more important then how to do it is the fact that this method is used by others - I would hate to do something that was frowned upon...
    What do you mean by "this method"?

  9. #9

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Folder and file processing

    Quote Originally Posted by Hack
    What do you mean by "this method"?
    DIR() and FILECOPY() - until now I had only used FSO for file processing like this - and that required extra components on install.

    I don't know what's tried-and-true in the VB/PC world - I'm a mainframe programmer from the 1980's...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Folder and file processing

    Dir and FileCopy are built in functions, and have been used since the dawn of VB Time. Long before there was an FSO, there was a Dir() and a FileCopy().

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