I have an excel spreadsheet which identifies where image files need to be moved.
At the moment all the image files are located in one large folder on my external hard drive f:\
So, I want to move all the images that correspond to the folder name which is recorded in excel spreadhseet
I have 3,093 folders with approximately 6,000 images.
I don't know programming. I found the script below but it asks for a source and destination folder. I have manually gotten through 300 folders but it's taking ages.
Would anyone be able to help me do this in one F5 run
Folder Name File Name
[TABLE="width: 192"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]301
[/TD]
[TD] 43310.tif
[/TD]
[/TR]
[TR]
[TD]302
[/TD]
[TD] 26189.tif
[/TD]
[/TR]
[TR]
[TD]302
[/TD]
[TD] 37000.tif
[/TD]
[/TR]
[TR]
[TD]303
[/TD]
[TD] 43205.tif
[/TD]
[/TR]
[TR]
[TD]304
[/TD]
[TD] 25866.tif
[/TD]
[/TR]
[TR]
[TD]304
[/TD]
[TD] 32694.tif
[/TD]
[/TR]
</tbody>[/TABLE]
Sub copyfiles()
'Updateby Extendoffice
Dim xRg As Range, xCell As Range
Dim xSFileDlg As FileDialog, xDFileDlg As FileDialog
Dim xSPathStr As Variant, xDPathStr As Variant
Dim xVal As String
On Error Resume Next
Set xRg = Application.InputBox("Please select the file names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8)
If xRg Is Nothing Then Exit Sub
Set xSFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xSFileDlg.Title = "Please select the original folder:"
If xSFileDlg.Show <> -1 Then Exit Sub
xSPathStr = xSFileDlg.SelectedItems.Item(1) & ""
Set xDFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xDFileDlg.Title = "Please select the destination folder:"
If xDFileDlg.Show <> -1 Then Exit Sub
xDPathStr = xDFileDlg.SelectedItems.Item(1) & ""
For Each xCell In xRg
xVal = xCell.Value
If TypeName(xVal) = "String" And xVal <> "" Then
FileCopy xSPathStr & xVal, xDPathStr & xVal
End If
Next
End Sub
At the moment all the image files are located in one large folder on my external hard drive f:\
So, I want to move all the images that correspond to the folder name which is recorded in excel spreadhseet
I have 3,093 folders with approximately 6,000 images.
I don't know programming. I found the script below but it asks for a source and destination folder. I have manually gotten through 300 folders but it's taking ages.
Would anyone be able to help me do this in one F5 run
Folder Name File Name
[TABLE="width: 192"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]301
[/TD]
[TD] 43310.tif
[/TD]
[/TR]
[TR]
[TD]302
[/TD]
[TD] 26189.tif
[/TD]
[/TR]
[TR]
[TD]302
[/TD]
[TD] 37000.tif
[/TD]
[/TR]
[TR]
[TD]303
[/TD]
[TD] 43205.tif
[/TD]
[/TR]
[TR]
[TD]304
[/TD]
[TD] 25866.tif
[/TD]
[/TR]
[TR]
[TD]304
[/TD]
[TD] 32694.tif
[/TD]
[/TR]
</tbody>[/TABLE]
Sub copyfiles()
'Updateby Extendoffice
Dim xRg As Range, xCell As Range
Dim xSFileDlg As FileDialog, xDFileDlg As FileDialog
Dim xSPathStr As Variant, xDPathStr As Variant
Dim xVal As String
On Error Resume Next
Set xRg = Application.InputBox("Please select the file names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8)
If xRg Is Nothing Then Exit Sub
Set xSFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xSFileDlg.Title = "Please select the original folder:"
If xSFileDlg.Show <> -1 Then Exit Sub
xSPathStr = xSFileDlg.SelectedItems.Item(1) & ""
Set xDFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xDFileDlg.Title = "Please select the destination folder:"
If xDFileDlg.Show <> -1 Then Exit Sub
xDPathStr = xDFileDlg.SelectedItems.Item(1) & ""
For Each xCell In xRg
xVal = xCell.Value
If TypeName(xVal) = "String" And xVal <> "" Then
FileCopy xSPathStr & xVal, xDPathStr & xVal
End If
Next
End Sub