iknowu99
Well-known Member
- Joined
- Dec 26, 2004
- Messages
- 1,158
- Office Version
- 2016
I would like to copy all folders/subfolders/files from CD to hard drive and exclude files larger than 100mb. Currently i am using the following code and it's eating up my harddrive!!
Rich (BB code):
Option Explicit
Private Declare Function GetVolumeInformation Lib "Kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" ( _
ByVal lpstrCommand As String, _
ByVal lpstrReturnStr As Any, _
ByVal wReturnLen As Long, _
ByVal hCallBack As Long) As Long
Sub CopyCD()
Application.ScreenUpdating = False
Dim x_start As Double
x_start = Timer
Const OverWriteFiles = True
Dim sPasteFolder As String
Dim oFSO As Object
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim Serial As Long, VName As String, FSName As String
'Create buffers
VName = String$(255, Chr$(0))
FSName = String$(255, Chr$(0))
'Get the volume information
GetVolumeInformation "D:\", VName, 255, Serial, 0, 0, FSName, 255
'Strip the extra chr$(0)'s
VName = Left$(VName, InStr(1, VName, Chr$(0)) - 1)
FSName = Left$(FSName, InStr(1, FSName, Chr$(0)) - 1)
'MsgBox "The Volume name of D:\ is '" + VName + "', the File system name of Q:\ is '" + FSName + "' and the serial number of Q:\ is '" + Trim(Str$(Serial)) + "'", vbInformation + vbOKOnly
sPasteFolder = "C:\Testing\"
If FileFolderExists(sPasteFolder) = False Then MkDir (sPasteFolder)
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.CopyFolder "D:*", sPasteFolder
oFSO.CopyFile "D:\*.*", sPasteFolder
Call OpenCD
MsgBox (Timer - x_start)
End Sub
Public Function FileFolderExists(strFullPath As String) As Boolean
If Not Dir(strFullPath, vbDirectory) = vbNullString Then FileFolderExists = True
End Function