|
-
Sep 13th, 2000, 03:32 AM
#1
Thread Starter
Addicted Member
I have a folder with many files of different types in it. I need to know how would I copy each filename and the file size into an array. Then I want to copy files with a certain extension over to a different folder and Verify that from the file attributes that the files copied over are the same size etc. as the origional files.
If anyone has some code or some suggestions on how to do this I would really appreciate it. Thanks a lot for your help.
JK
-
Sep 13th, 2000, 05:56 AM
#2
Addicted Member
This example loads all the filenames in "D:\" into the variable FileNames(), at the same time copying the text files in "D:\" into "D:\Temporary".
Code:
Dim FileNames(), i, temp, MyPath, Ext
Sub Test()
ReDim FileNames(0)
MyPath = "D:\"
temp = Dir(MyPath)
Do
temp = Dir
If temp <> "" Then
i = i + 1
ReDim Preserve FileNames(i)
FileNames(i) = temp
Ext = UCase(Mid(temp, InStr(1, temp, ".") + 1, 3))
If Ext = "DLL" Then
FileCopy MyPath & temp, "D:\Temporary\" & temp
End If
End If
Loop Until temp = ""
End Sub
Hope that helps.
-
Sep 13th, 2000, 06:11 AM
#3
Thread Starter
Addicted Member
That's great, thanks a lot. Any idea on how to compare the size of the files in the origional folder to the size of the files in the new folder. Thanks again
-
Sep 13th, 2000, 06:35 AM
#4
transcendental analytic
Should be easy, here you can use EnumDir sub to populate stringarrays with the files in a directory. Use filelen to get the size or a file
Code:
Sub EnumDir(Byref edir() as string,path as string)
Dim n as integer, a as string
A=Dir(path)
Do while len(A)
Redim preserve edir(n)
edir(n)=A
n=n+1
A=DIR
Loop
end sub
Sub main()
Dim olddir() as string,newdir() as string
enumdir olddir(),"D:\"
enumdir newdir(),"D:\Newdir"
for n=0 to ubound(olddir)
if filelen(olddir(n))=filelen(newdir(n)) then
'files are the same size
end if
next n
end sub
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Sep 13th, 2000, 06:38 AM
#5
Thread Starter
Addicted Member
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
|