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!
Re: Folder and file processing
i would use the native FileCopy() function.
casey.
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?
Re: Folder and file processing
Something like
VB Code:
Dim strLoadFiles As String
'once for all pdf files
LoadFiles = Dir("c:\path\somefolder & "\*.pdf")
Do While LoadFiles > ""
gsDocFileNameAndPath = "c:\path\somefolder "\" & LoadFiles
Call ProcessImportFiles(LoadFiles, frmMain)
LoadFiles = Dir
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.
Re: Folder and file processing
ok - found a DIR() function - me thinks that could be the final answer...
Re: Folder and file processing
I found it a minute before you did... :D
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...
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"?
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...
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().