Copy folder from new folder as per the excel list

punit83

Board Regular
Joined
Jan 17, 2018
Messages
66
Office Version
  1. 2019
Platform
  1. Windows
Hello !

I have 5000 product video/photo in initial folder in a main folder and i want to copy few video/photo with their initial folder to new folder.

Product Id are in excel in list.i want to copy only that folder which are in list in excel.

can any one pls provide solution for this.


i am newbie.

Thanks in Advance.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
i want to copy few video/photo

To COPY SOME of the video/photo from a folder C:\Test\A2 to folder C:\Test\A3
- destination folder MUST exist BEFORE files are copied

One photo
Code:
Sub copyFile()
    Dim sourceStr As String, destinationStr As String, fName As String
    fName = "ABC.jpg"
    sourceStr = "[COLOR=#008080]C:\Test\A2\[/COLOR]" & fName
    destinationStr = "[COLOR=#008080]C:\Test\A3\[/COLOR]" & fName
    
    FileCopy sourceStr, destinationStr
End Sub
Photos listed (list specifies extension)
Code:
Sub copyFilesListed1()
    Dim rng As Range, cel As Range, sourceStr As String, destinationStr As String, fName As String
    Set rng = Range("A2:A10")
    For Each cel In rng

        fName = cel.Value
        sourceStr = "[COLOR=#008080]C:\Test\A2\[/COLOR]" & fName
        destinationStr = "[COLOR=#008080]C:\Test\A3\[/COLOR]" & fName
        
        FileCopy sourceStr, destinationStr
    Next cel
End Sub
Photos listed (list does not specify extension)
- photos and video need listing separately (different extensions)
Code:
Sub copyFilesListed2()
    Dim rng As Range, cel As Range, sourceStr As String, destinationStr As String, fName As String
    Set rng = Range("A2:A10")
    For Each cel In rng

        fName = cel.Value[COLOR=#ff0000] & ".jpg"[/COLOR]
        sourceStr = "[COLOR=#008080]C:\Test\A2\[/COLOR]" & fName
        destinationStr = "[COLOR=#008080]C:\Test\A3\[/COLOR]" & fName

        FileCopy sourceStr, destinationStr
    Next cel
End Sub


If something does not work for you, please post the code you are using inside code tags - click on # icon above reply window and paste your code inside the tags that appear
[ CODE ] code goes here [ /CODE ]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,580
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top