|
-
Sep 6th, 2000, 10:34 AM
#1
Thread Starter
Addicted Member
Here's what I have. I want to look in the folder D:\Credit\newFolder for a number of files all with the same file extension. I want to know how to open this pariticular folder(D:\Credit\newFolder) to look for the file extensions .JPG.
<code>
'Taken from Crispin
Option Explicit
Dim fs As New FileSystemObject
Dim folCurrent
Dim ColFiles
Dim VarCurrentFile
Private Sub doJpg()
'can I add in here a open statement for a folder????
Set folCurrent = fs.GetFolder(Text1.Text)
Set ColFiles = folCurrent.Files
fs.CreateFolder (folCurrent & "\NEWDIR")
For Each VarCurrentFile In ColFiles
If UCase(Right$(VarCurrentFile, 3)) = "JPG" Then
'process the filenames one by one
Debug.Print VarCurrentFile
fs.CopyFile VarCurrentFile, folCurrent & "\NEWDIR", True
end if
Next
End Sub
</code>
Thanks a lot for all your help
JK
-
Sep 6th, 2000, 10:53 AM
#2
Lively Member
The DIR Function may help you out here:
Code:
Dim sDir As String
Dim sDir2 As String
sDir = "c:\temp\*.jpg"
sDir2 = Dir(sDir, vbDirectory)
Do While sDir2 <> ""
MsgBox ("Filename: " & sDir2)
Loop
The above code will give me a listing of all .JPG files in the c:\temp directory one at a time. In the above example, it will MsgBox each one.
-
Sep 6th, 2000, 10:54 AM
#3
Lively Member
dim dirname as string, newdir as string
dim f as string
dirname = "D:\Credit\newFolder\"
newdir = dirname & "NEWDIR"
mkdir newdir
newdir = newdir + "\"
f = Dir$(dirname & "*.jpg")
do while f <> ""
filecopy dirname & f, newdir & f
f = Dir$
Loop
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|