stan@croftmetals.com
Feb 2nd, 2001, 08:18 AM
My problem is I can't get this program to rename multiple files."BinRename("C:\*.bat", "C:\*.txt")"
It will only rename one file. Can any one suggest how I could do this?
Thanks,
Stan
Code:
-------------
Option Explicit
Const FO_MOVE = &H1
Const FO_COPY = &H2
Const FO_DELETE = &H3
Const FO_RENAME = &H4
Const FOF_SILENT = &H4
Const FOF_NOCONFIRMATION = &H10
Const FOF_FILESONLY = &H80
Const FOF_MULTIDESTFILES = &H1
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
End Type
' Functions
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) As Long
Private Function BinRename(FromFileName As String, ToFileName As String) As Boolean
Dim FileOperation As SHFILEOPSTRUCT
Dim lReturn As Long
With FileOperation
.wFunc = FO_RENAME
.pFrom = FromFileName
.pTo = ToFileName
.fFlags = FOF_MULTIDESTFILES
End With
lReturn = SHFileOperation(FileOperation)
BinRename = (lReturn = 0)
End Function
'Sub Click
Private Sub Command1_Click()
Dim lResult As Long, bRetVal As Long, SHF As SHFILEOPSTRUCT, FileOperation As SHFILEOPSTRUCT
SHF.hwnd = hwnd
SHF.wFunc = FO_COPY ' copy
SHF.pFrom = "c:\test\*.bat"
SHF.pTo = "c:\"
lResult = SHFileOperation(SHF)
If lResult Then
MsgBox "Error in Copying files", vbInformation, "Error 1"
End If
bRetVal = BinRename("C:\*.bat", "C:\*.txt")
Unload Form1
End Sub
'Sub Form
Private Sub Form_Load()
Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
End Sub
It will only rename one file. Can any one suggest how I could do this?
Thanks,
Stan
Code:
-------------
Option Explicit
Const FO_MOVE = &H1
Const FO_COPY = &H2
Const FO_DELETE = &H3
Const FO_RENAME = &H4
Const FOF_SILENT = &H4
Const FOF_NOCONFIRMATION = &H10
Const FOF_FILESONLY = &H80
Const FOF_MULTIDESTFILES = &H1
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
End Type
' Functions
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) As Long
Private Function BinRename(FromFileName As String, ToFileName As String) As Boolean
Dim FileOperation As SHFILEOPSTRUCT
Dim lReturn As Long
With FileOperation
.wFunc = FO_RENAME
.pFrom = FromFileName
.pTo = ToFileName
.fFlags = FOF_MULTIDESTFILES
End With
lReturn = SHFileOperation(FileOperation)
BinRename = (lReturn = 0)
End Function
'Sub Click
Private Sub Command1_Click()
Dim lResult As Long, bRetVal As Long, SHF As SHFILEOPSTRUCT, FileOperation As SHFILEOPSTRUCT
SHF.hwnd = hwnd
SHF.wFunc = FO_COPY ' copy
SHF.pFrom = "c:\test\*.bat"
SHF.pTo = "c:\"
lResult = SHFileOperation(SHF)
If lResult Then
MsgBox "Error in Copying files", vbInformation, "Error 1"
End If
bRetVal = BinRename("C:\*.bat", "C:\*.txt")
Unload Form1
End Sub
'Sub Form
Private Sub Form_Load()
Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
End Sub