VBScript that copy all lib/dll/map/pdb file to current dir of the script file
'*************copy DLL/LIB/PDB/MAP file to wanted directory
'*************usage: put copy_libs.vbs at the destionation directory
'*************usage: double click on copy_libs.vbs in exploerer at the destionation directory
'*************destionation dir should look like c:\xxx\debug in order to copy files of debug version
'*************or c:\yyy\release in order to copy files of release version
'*************so that the script can find debug/release files appropriately
'*************Author: Onega(www.fruitfruit.com http://fruitfruit.blogspot.com)
'*************Warning: Use it at your own risk!
'*************
'*************2004/12/28
On Error Resume Next
Dim source_dir
Dim dest_dir
Dim source_path_key
Dim check_script_path '''''''check path of this script file to find if release or debug
source_dir = "C:\onega"
check_script_path = InStr(1,WScript.ScriptFullName , "Release",vbTextCompare)
If IsNull(check_script_path) OR check_script_path = 0 Then
source_path_key = "Debug"
Else
source_path_key = "Release"
End If
Set IFileSystem3 = CreateObject("Scripting.FileSystemObject")
dest_dir = IFileSystem3.GetParentFolderName(WScript.ScriptFullName) & "\"
set IFolder = IFileSystem3.GetFolder(source_dir)
start_time = Now()
clear_folder IFolder
MsgBox "Copy libraries " &source_dir & " to " & dest_dir & " use time " & CStr( DateDiff("s", Now(),start_time) ) & " seconds"
Function clear_folder( folder )
set IFileCollection = folder.Files
Dim check_path
check_path = InStr(1,folder.Path, source_path_key,vbTextCompare)
If IsNull(check_path) or check_path = 0 Then
'''''''''''files of this folder can be ignored,
'''''''''''only its sub folders need to be checked
Else
For each file in IFileCollection
is_lib_file( file )
Next
End If
For each sub_folder in folder.SubFolders
clear_folder sub_folder
Next
End Function
Function is_lib_file(src_file)
Dim path
path = src_file.Path
Dim check_path
is_lib_file = false
Dim file_ext
Dim dest_file_path
'''''''''''''''''Dim src_file
Dim dest_file
Dim src_file_name '''file name only , no path information
check_path = InStr(1,path, source_path_key,vbTextCompare)
If IsNull(check_path) or check_path = 0 Then
is_lib_file = false
Else
file_ext = IFileSystem3.GetExtensionName(path)
If StrComp( file_ext,"obj",vbTextCompare) = 0 Then
Exit Function
End If
If StrComp( file_ext,"sbr",vbTextCompare) = 0 Then
Exit Function
End If
If StrComp( file_ext,"idb",vbTextCompare) = 0 Then
Exit Function
End If
src_file_name = IFileSystem3.GetFileName(path)
If StrComp( src_file_name,"vc60.pdb",vbTextCompare) = 0 Then
Exit Function
End If
If StrComp( src_file_name,"vc70.pdb",vbTextCompare) = 0 Then
Exit Function
End If
If StrComp( file_ext,"dll",vbTextCompare) = 0 OR StrComp( file_ext,"lib",vbTextCompare) = 0 OR StrComp( file_ext,"pdb",vbTextCompare) = 0 OR StrComp( file_ext,"map",vbTextCompare) = 0 OR StrComp( file_ext,"pdb",vbTextCompare) = 0 OR StrComp( file_ext,"exe",vbTextCompare) = 0 Then
''''''''''check file size, modify time
dest_file_path = dest_dir & src_file_name
If IFileSystem3.FileExists(dest_file_path) Then
''''''''''''''Set src_file = IFileSystem3.GetFile( path)
Set dest_file = IFileSystem3.GetFile(dest_file_path)
If src_file.DateLastModified = dest_file.DateLastModified and src_file.Size = dest_file.Size Then
''''''''''''''' two files are identical
Else
IFileSystem3.CopyFile path, dest_file_path, true
End If
Else
IFileSystem3.CopyFile path, dest_file_path, true
End If
is_lib_file = true
End If
End if
End Function
'*************usage: put copy_libs.vbs at the destionation directory
'*************usage: double click on copy_libs.vbs in exploerer at the destionation directory
'*************destionation dir should look like c:\xxx\debug in order to copy files of debug version
'*************or c:\yyy\release in order to copy files of release version
'*************so that the script can find debug/release files appropriately
'*************Author: Onega(www.fruitfruit.com http://fruitfruit.blogspot.com)
'*************Warning: Use it at your own risk!
'*************
'*************2004/12/28
On Error Resume Next
Dim source_dir
Dim dest_dir
Dim source_path_key
Dim check_script_path '''''''check path of this script file to find if release or debug
source_dir = "C:\onega"
check_script_path = InStr(1,WScript.ScriptFullName , "Release",vbTextCompare)
If IsNull(check_script_path) OR check_script_path = 0 Then
source_path_key = "Debug"
Else
source_path_key = "Release"
End If
Set IFileSystem3 = CreateObject("Scripting.FileSystemObject")
dest_dir = IFileSystem3.GetParentFolderName(WScript.ScriptFullName) & "\"
set IFolder = IFileSystem3.GetFolder(source_dir)
start_time = Now()
clear_folder IFolder
MsgBox "Copy libraries " &source_dir & " to " & dest_dir & " use time " & CStr( DateDiff("s", Now(),start_time) ) & " seconds"
Function clear_folder( folder )
set IFileCollection = folder.Files
Dim check_path
check_path = InStr(1,folder.Path, source_path_key,vbTextCompare)
If IsNull(check_path) or check_path = 0 Then
'''''''''''files of this folder can be ignored,
'''''''''''only its sub folders need to be checked
Else
For each file in IFileCollection
is_lib_file( file )
Next
End If
For each sub_folder in folder.SubFolders
clear_folder sub_folder
Next
End Function
Function is_lib_file(src_file)
Dim path
path = src_file.Path
Dim check_path
is_lib_file = false
Dim file_ext
Dim dest_file_path
'''''''''''''''''Dim src_file
Dim dest_file
Dim src_file_name '''file name only , no path information
check_path = InStr(1,path, source_path_key,vbTextCompare)
If IsNull(check_path) or check_path = 0 Then
is_lib_file = false
Else
file_ext = IFileSystem3.GetExtensionName(path)
If StrComp( file_ext,"obj",vbTextCompare) = 0 Then
Exit Function
End If
If StrComp( file_ext,"sbr",vbTextCompare) = 0 Then
Exit Function
End If
If StrComp( file_ext,"idb",vbTextCompare) = 0 Then
Exit Function
End If
src_file_name = IFileSystem3.GetFileName(path)
If StrComp( src_file_name,"vc60.pdb",vbTextCompare) = 0 Then
Exit Function
End If
If StrComp( src_file_name,"vc70.pdb",vbTextCompare) = 0 Then
Exit Function
End If
If StrComp( file_ext,"dll",vbTextCompare) = 0 OR StrComp( file_ext,"lib",vbTextCompare) = 0 OR StrComp( file_ext,"pdb",vbTextCompare) = 0 OR StrComp( file_ext,"map",vbTextCompare) = 0 OR StrComp( file_ext,"pdb",vbTextCompare) = 0 OR StrComp( file_ext,"exe",vbTextCompare) = 0 Then
''''''''''check file size, modify time
dest_file_path = dest_dir & src_file_name
If IFileSystem3.FileExists(dest_file_path) Then
''''''''''''''Set src_file = IFileSystem3.GetFile( path)
Set dest_file = IFileSystem3.GetFile(dest_file_path)
If src_file.DateLastModified = dest_file.DateLastModified and src_file.Size = dest_file.Size Then
''''''''''''''' two files are identical
Else
IFileSystem3.CopyFile path, dest_file_path, true
End If
Else
IFileSystem3.CopyFile path, dest_file_path, true
End If
is_lib_file = true
End If
End if
End Function