Note: The other languages of the website are Google-translated. Back to English
Увійти  \/ 
x
or
x
Реєстрація  \/ 
x

or

Як скопіювати або перемістити файли з однієї папки в іншу на основі списку в Excel? 

Якщо у вас є список імен файлів у стовпці на аркуші, а файли знаходяться в папці на вашому комп'ютері. Але тепер вам потрібно перемістити або скопіювати ці файли, імена яких вказані на аркуші, з їх вихідної папки в іншу, як показано на наступному знімку екрана. Як ви могли виконати це завдання якомога швидше в Excel?

Копіюйте або переміщуйте файли з однієї папки в іншу на основі списку в Excel із кодом VBA


Копіюйте або переміщуйте файли з однієї папки в іншу на основі списку в Excel із кодом VBA

Щоб перемістити файли з однієї папки в іншу на основі списку імен файлів, такий код VBA може зробити вам послугу, зробіть так:

1. Утримуйте клавішу Alt + F11 клавіші в Excel, і він відкриває Microsoft Visual Basic для додатків вікна.

2. Клацання Insert > Модуліта вставте наступний код VBA у вікно модуля.

Код VBA: переміщення файлів з однієї папки в іншу на основі списку в Excel

Sub movefiles()
'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
            Kill xSPathStr & xVal
        End If
    Next
End Sub

3. А потім натисніть F5 клавішу для запуску цього коду, і з'явиться підказка, щоб нагадати вам про вибір комірок, що містять імена файлів, див. знімок екрана:

4. Потім натисніть OK і у спливаючому вікні виберіть папку, яка містить файли, з яких ви хочете перемістити, див. знімок екрана:

5. А потім клацніть OK, перейдіть до вибору цільової папки, де ви хочете знайти файли, в іншому спливаючому вікні, див. знімок екрана:

6. Нарешті, клацніть OK щоб закрити вікно, і тепер файли були переміщені в іншу папку, яку ви вказали на основі імен файлів у списку робочих аркушів, див. знімок екрана:

примітки: Якщо ви просто хочете скопіювати файли в іншу папку, але зберегти оригінальні файли, застосуйте наведений нижче код VBA:

Код VBA: копіюйте файли з однієї папки в іншу на основі списку в Excel

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

Найкращі інструменти для підвищення продуктивності офісу

Kutools для Excel вирішує більшість ваших проблем і збільшує продуктивність на 80%

  • Повторне використання: Швидко вставте складні формули, діаграми і все, що ви використовували раніше; Шифрувати комірки з паролем; Створити список розсилки та надсилати електронні листи ...
  • Супер формула бар (легко редагувати кілька рядків тексту та формули); Макет читання (легко читати та редагувати велику кількість комірок); Вставте у відфільтрований діапазон...
  • Об’єднати клітинки / рядки / стовпці без втрати даних; Вміст розділених комірок; Об'єднати повторювані рядки / стовпці... Запобігання дублюючим клітинам; Порівняйте діапазони...
  • Виберіть Повторюваний або Унікальний Рядки; Виберіть Пусті рядки (усі клітинки порожні); Супер знахідка та нечітка знахідка у багатьох робочих зошитах; Випадковий вибір ...
  • Точна копія Кілька клітинок без зміни посилання на формулу; Автоматичне створення посилань на кілька аркушів; Вставте кулі, Прапорці та інше ...
  • Витяг тексту, Додати текст, Видалити за позицією, Видаліть пробіл; Створення та друк проміжних підсумків підкачки; Перетворення вмісту комірок та коментарів...
  • Супер фільтр (зберегти та застосувати схеми фільтрів до інших аркушів); Розширене сортування за місяцем / тижнем / днем, частотою та іншим; Спеціальний фільтр жирним, курсивом ...
  • Поєднайте робочі зошити та робочі аркуші; Об’єднати таблиці на основі ключових стовпців; Розділіть дані на кілька аркушів; Пакетне перетворення xls, xlsx та PDF...
  • Понад 300 потужних функцій. Підтримує Office / Excel 2007-2019 та 365. Підтримує всі мови. Простота розгортання на вашому підприємстві чи в організації. Повна функція 30-денної безкоштовної пробної версії. 60-денна гарантія повернення грошей.
вкладка kte 201905

Вкладка Office забезпечує інтерфейс з вкладками для Office і значно спрощує вашу роботу

  • Увімкніть редагування та читання на вкладках у Word, Excel, PowerPoint, Publisher, Access, Visio та Project.
  • Відкривайте та створюйте кілька документів на нових вкладках того самого вікна, а не в нових вікнах.
  • Збільшує вашу продуктивність на 50% та зменшує сотні клацань миші для вас щодня!
дно офісної таблиці
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Bob · 9 days ago
    Don't forget to add your file extensions
  • To post as a guest, your comment is unpublished.
    JayV · 28 days ago
    Hi, been using this code for a while. Recently, I've ran into an issue were the code asks to select file names, original folder, and destination and then doesn't actually run or copy any of the files. Any reason this might be? 
    • To post as a guest, your comment is unpublished.
      skyyang · 27 days ago
      Hello, JayV,
      Maybe you should copy and paste the code to your new workbook again, and please check if there are corresponding files names exist in the cell list of the worksheet.
      Thank you!
  • To post as a guest, your comment is unpublished.
    MarcW · 2 months ago
    Is pressing "F5" supposed to take me back to the last active sheet when the VBA module runs? I am running Excel 2019 (almost equiv. to Excel 365). Is there something else I should do instead to run it?
  • To post as a guest, your comment is unpublished.
    Evelyne · 3 months ago
    Everything was OK for me (800 files to copy from a folder containing 10000 files).
    Many thanks.
  • To post as a guest, your comment is unpublished.
    marc_vie · 4 months ago
    Excellent macro.
    How can this be modified for my need case as below. I have zero experience in VBA.
    The source folders (3 – zmf, vek, num) and destination folders (4 – jack, james, john, jane) names and paths are constant.
    Source folders (3)
    \\192.168.xx.x\ma\zmf\ (files here – 123.wav, 456.wav, etc)
    \\192.168.xx.x\ma\vek\ (files here – abc.wav, etc)
    \\192.168.xx.x\ma\num\ (files here – ghi.wav, etc)
    Destination folders (4)
    \\192.168.xx.xx\ba\jack\
    \\192.168.xx.xx\ba\james\
    \\192.168.xx.xx\ba\john\
    \\192.168.xx.xx\ba\jane\
    In Excel sheet, in Column A I have the list of files (will change on a daily basis) which have to be COPIED (not moved) to the folder in Column B (the folder in which the files are contained (zmf, vek, num) also have to be copied.
    For example, 123.wav has to be copied to the folder “jack” such as \\192.168.xx.xx\ba\jack\zmf\123.wav
        abc.wav has to be copied to the folder “jane” such as \\192.168.xx.xx\ba\jane\vek\abc.wav
        ghi.wav also has to be copied to the folder “jack” such as \\192.168.xx.xx\ba\jack\num\ghi.wav
        
    Column A    Column B
    Files in Source folders    Destination folders (constant)
    123.wav    jack
    456.wav    james
    789.wav    john
    abc.wav    jane
    def.wav    james
    ghi.wav    jack

    Can anyone help with modifying this macro please?
  • To post as a guest, your comment is unpublished.
    G · 10 months ago
    I have a list of 10000 files that need to be moved but the above code stops after taking source file location. Kindly let me know if I need to change anything in the code.
  • To post as a guest, your comment is unpublished.
    enesa20 · 1 years ago
    Hello,
    I need some additional help with the VBA code.

    My excel list has names like this:

    ABCDEF

    The .jpg files Im trying to match are:

    ABCDEF_1, ABCDEF_2, ABCDEF_3 ....

    Some names on the list has more than 1 .jpg files and I want ALL of those files to be copied. Could anybody please modify the code accordingly?,,

    Thank you very much!!
  • To post as a guest, your comment is unpublished.
    Walter · 1 years ago
    Hallo,
    what must i change when i always want to search pdf and jpg files and then copy thes in only one destination folder?
  • To post as a guest, your comment is unpublished.
    Joelle · 1 years ago
    Thank you! you are a life saver!
  • To post as a guest, your comment is unpublished.
    Puneet Goel · 1 years ago
    Thanks a lot.....It really worked very well and solved the issue completely
  • To post as a guest, your comment is unpublished.
    Steve · 1 years ago
    Can anyone help to adapt the code to search specific files in folder and subfolers then copy it to destination?
    • To post as a guest, your comment is unpublished.
      skyyang · 1 years ago
      Hello, Steve,
      To copy the files from one folder including the subfolders to another folder based on the list in sheet, please apply the following code.
      Please try, hope it can help you!
      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 Dim fso As Object, folder1 As Object 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) & "\" Call sCopyFiles(xRg, xSPathStr, xDPathStr) End Sub Sub sCopyFiles(xRg As Range, xSPathStr As Variant, xDPathStr As Variant) Dim xCell As Range Dim xVal As String Dim xFolder As Object Dim fso As Object Dim xF As Object Dim xStr As String Dim xFS As Object Dim xI As Integer On Error Resume Next If Dir(xDPathStr, vbDirectory) = "" Then MkDir (xDPathStr) End If For xI = 1 To xRg.Count Set xCell = xRg.Item(xI) xVal = xCell.Value If TypeName(xVal) = "String" And Not (xVal = "") Then On Error GoTo E1 If Dir(xSPathStr & xVal, 16) <> Empty Then FileCopy xSPathStr & xVal, xDPathStr & xVal End If End If E1: Next xI On Error Resume Next Set fso = CreateObject("Scripting.FileSystemObject") Set xFS = fso.GetFolder(xSPathStr) For Each xF In xFS.SubFolders xStr = xDPathStr & "\" & xF.Name Call sCopyFiles(xRg, xF.ShortPath & "\", xStr & "\") If (CreateObject("scripting.FileSystemObject").GetFolder(xStr).Files.Count = 0) _ And (CreateObject("scripting.FileSystemObject").GetFolder(xStr).SubFolders.Count = 0) Then RmDir xStr End If Next End Sub

      • To post as a guest, your comment is unpublished.
        HelpMe · 1 years ago
        Can You help me with this? I copied the whole code and it's fine but I'd like to use only part of the file name and not create folder when copyiong file from subfolder. Let's say I have folder AAA with file 123-321.pdf and subfolder BBB with file 123_111.pdf
        In Excel column i have only "123" without any extension or "-" or "_" and I want to copy all files containing "123" from folder AAA to new folder CCC.

        Right now this code would only copy a files when the full name is written in excel column like "123-321.pdf" or would create whole new subfolder BBB in folder CCC if you look for "123_111.pdf"

        Looking forward to Your response as I'm not even a newbie in VBA just passing by :D
  • To post as a guest, your comment is unpublished.
    priya · 1 years ago
    works perfectly like a charm
  • To post as a guest, your comment is unpublished.
    sd · 1 years ago
    can anyone help to adapt this excellent code so the file range is fixed eg all filenames in column A until empty cell and pre set the from path as i always copy from the same source
    • To post as a guest, your comment is unpublished.
      mubashirazizch@gmail.com · 1 years ago
      use this code and keep A1 cell blank

      Sub Copymy1()
      Dim filelist As Variant
      Dim i As Long
      Dim filetocopy As String
      Dim copysource As String
      Dim Copydestination As String

      copysource = "C:\copyfrom\"
      Copydestination = "C:copyto\"
      filelist = ActiveWorkbook.Sheets(1).Range("A1").CurrentRegion.Value
      For i = 2 To UBound(filelist)
      FName = Dir$(copysource & "*.*")
      While FName <> ""
      If UCase(FName) = UCase(filelist(i, 1)) Then
      FileCopy copysource & FName, Copydestination & FName

      End If
      FName = Dir$()
      Wend
      Next i

      End Sub
  • To post as a guest, your comment is unpublished.
    Exe · 1 years ago
    Sorry I just saw the second script below...

    I do have one more (applicable) query... Is there a way to make the script pick a filtered selection on a column? Instead of consecutive cell ranges.. would there be a way to make it pick only some specific rows after a filter is applied?
    THANK YOU
  • To post as a guest, your comment is unpublished.
    Exe · 1 years ago
    Thank you SO MUCH for this. It worked perfectly at my end.
    I have one question... is it possible to modify this to copy the files into the second path instead of moving them? I would need to apply this feature but I do need the source files to remain in the source folders.
    Thank you!!!
  • To post as a guest, your comment is unpublished.
    Phil · 1 years ago
    Hi, Can this code be tweaked to look for partial file names using a wildcard? Thanks
  • To post as a guest, your comment is unpublished.
    sabin348 · 1 years ago
    How could this be adapted to paste into a list of multiple file paths instead of one path at a time?
    • To post as a guest, your comment is unpublished.
      skyyang · 1 years ago
      Hello, sabin,
      Do you want to copy and paste the files which from multiple original folders instead of only one folder?
      • To post as a guest, your comment is unpublished.
        andrea · 1 years ago
        yes please

  • To post as a guest, your comment is unpublished.
    mmarques09 · 1 years ago
    If the reference doesn't exist the code break
    wich line shall I had to the code do a jump through the next reference without stop
  • To post as a guest, your comment is unpublished.
    Marco · 1 years ago
    An what happen if the file doesn't existe in the origin folder?
    the code breaks

    The code shall has a line to jump to another reference if doesn't exist
  • To post as a guest, your comment is unpublished.
    Kevin · 2 years ago
    HI, I am not an expert in VBA but need your Module and I did as you instruct but nothing copied from source folder to the new folder. and no error is shown
  • To post as a guest, your comment is unpublished.
    inasr · 2 years ago
    Any update of how to search on folder and subfolders
    • To post as a guest, your comment is unpublished.
      skyyang · 2 years ago
      Hi, Nasr,
      To move files from folder and subfolders based on cell values, please apply the below VBA code:
      Please try, hope it can help you!

      Sub movefiles()
      '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
      Dim fso As Object, folder1 As Object
      ' 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) & "\"
      Call sMoveFiles(xRg, xSPathStr, xDPathStr)
      End Sub

      Sub sMoveFiles(xRg As Range, xSPathStr As Variant, xDPathStr As Variant)
      Dim xCell As Range
      Dim xVal As String
      Dim xFolder As Object
      Dim fso As Object
      Dim xF As Object
      Dim xStr As String
      Dim xFS As Object
      Dim xI As Integer
      On Error Resume Next
      If Dir(xDPathStr, vbDirectory) = "" Then
      MkDir (xDPathStr)
      End If
      For xI = 1 To xRg.Count
      Set xCell = xRg.Item(xI)
      xVal = xCell.Value
      If TypeName(xVal) = "String" And Not (xVal = "") Then
      On Error GoTo E1
      If Dir(xSPathStr & xVal, 16) <> Empty Then
      FileCopy xSPathStr & xVal, xDPathStr & xVal
      Kill xSPathStr & xVal
      End If
      End If
      E1:
      Next xI
      On Error Resume Next
      Set fso = CreateObject("Scripting.FileSystemObject")
      Set xFS = fso.GetFolder(xSPathStr)
      For Each xF In xFS.SubFolders
      xStr = xDPathStr & "\" & xF.Name ' Replace(xF.ShortPath, xSPathStr, xDPathStr)
      Call sMoveFiles(xRg, xF.ShortPath & "\", xStr & "\")
      If (CreateObject("scripting.FileSystemObject").GetFolder(xStr).Files.Count = 0) _
      And (CreateObject("scripting.FileSystemObject").GetFolder(xStr).SubFolders.Count = 0) Then
      RmDir xStr
      End If
      Next
      End Sub
      • To post as a guest, your comment is unpublished.
        Anita Singh · 10 months ago
        Hi skyyang,
        I want to copy or move files (.jpg, .png) any format from folder & its sub-folders. The above script is copying the whole folder containing the matched file

        Thanks & Regards,

      • To post as a guest, your comment is unpublished.
        inasr · 2 years ago
        That's perfect thank you
        but what about if I just wanted to copy files not moving it from subfolders only without the need of creating subfolders in the destination folder
        ie
        source folder X:\\parent
        inside parent is subfolders test1(file A), test2(file B) and test3(file C)
        then destination folder is "Y:\\destination" has all 3 files A, B, C without the subfolders

        Thank you very much
        • To post as a guest, your comment is unpublished.
          Mike · 2 years ago
          Hi Nasr, did you figure out how to do this? I am looking at a similar need at the moment.

          Copying a selection of files from various subfolders to a single folder
          • To post as a guest, your comment is unpublished.
            inasr · 2 years ago
            Hi Mike
            I kind of did BUT indirectly, so what I did is modify the code to copy the files not move them with the subfolder
            then with CMD file move the file from subfolders to the main folder then delete the empty subfolder
            this is what I did

            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
            Dim fso As Object, folder1 As Object
            ' 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) & "\"
            Call sCopyFiles(xRg, xSPathStr, xDPathStr)
            End Sub

            Sub sCopyFiles(xRg As Range, xSPathStr As Variant, xDPathStr As Variant)
            Dim xCell As Range
            Dim xVal As String
            Dim xFolder As Object
            Dim fso As Object
            Dim xF As Object
            Dim xStr As String
            Dim xFS As Object
            Dim xI As Integer
            On Error Resume Next
            If Dir(xDPathStr, vbDirectory) = "" Then
            MkDir (xDPathStr)
            End If
            For xI = 1 To xRg.Count
            Set xCell = xRg.Item(xI)
            xVal = xCell.Value
            If TypeName(xVal) = "String" And Not (xVal = "") Then
            On Error GoTo E1
            If Dir(xSPathStr & xVal, 16) <> Empty Then
            FileCopy xSPathStr & xVal, xDPathStr & xVal
            End If
            End If
            E1:
            Next xI
            On Error Resume Next
            Set fso = CreateObject("Scripting.FileSystemObject")
            Set xFS = fso.GetFolder(xSPathStr)
            For Each xF In xFS.SubFolders
            xStr = xDPathStr & "\" & xF.Name ' Replace(xF.ShortPath, xSPathStr, xDPathStr)
            Call sCopyFiles(xRg, xF.ShortPath & "\", xStr & "\")
            If (CreateObject("scripting.FileSystemObject").GetFolder(xStr).Files.Count = 0) _
            And (CreateObject("scripting.FileSystemObject").GetFolder(xStr).SubFolders.Count = 0) Then
            RmDir xStr
            End If
            Next
            End Sub



            then copy the following lines to a new notepad then save it as cmd call it whatever

            for /r %%a IN (*.*) do (
            move /y "%%a" "%cd%"
            )
            for /f "delims=" %%d in ('dir /s /b /ad ^| sort /r') do rd "%%d"



            make sure to copy the code as is 4 lines
            hope that help
            • To post as a guest, your comment is unpublished.
              Tim · 2 years ago
              You can achieve the same result using only the VBA if you add a ' before the & "\" & xF.Name in the below line.
              This still copies from subfolders but copies to a single level folder.

              xStr = xDPathStr & "\" & xF.Name ' Replace(xF.ShortPath, xSPathStr, xDPathStr)
              Becomes
              xStr = xDPathStr '& "\" & xF.Name ' Replace(xF.ShortPath, xSPathStr, xDPathStr)
            • To post as a guest, your comment is unpublished.
              inasr · 2 years ago
              make sure to put the cmd file in the same folder that you copy the files and subfolders to then double click it
  • To post as a guest, your comment is unpublished.
    ADOLFO · 2 years ago
    buenas noches, alguien sabe que tengo que modificar para que me mueva carpetas y no solo archivos?
  • To post as a guest, your comment is unpublished.
    jonathan · 2 years ago
    thanks so much !
  • To post as a guest, your comment is unpublished.
    Michael · 2 years ago
    Has anyone figured out how to copy files that are located in multiple subfolders of the main directory, and paste into another folder directory? Also does this transfer method only work for folders on the C drive? I am trying to copy files from our directory that includes multiple subfolders where several files are stored located in Microsoft Sharepoint, to a folder on my C drive.

    Any help would be much appreciated!
  • To post as a guest, your comment is unpublished.
    julien · 2 years ago
    hi do you know how to search also on the subfolder ?
  • To post as a guest, your comment is unpublished.
    technicallyspecific@gmail.com · 2 years ago
    Works great - thank you! However-->>>Can this be adjusted to use a PARTIAL FILE NAME? If so, can you help show how?
    In other words, if file name on the Excel sheet list of filenames is: OW4234TR_J19031.txt (I'd like it to only look at last 5 chars "19031" which is a Julian Date and move a range of files... (anything with a Julian Date of 19092 thru 19120) into the March folder.. The ultimate over-arching task is to locate any files that have Julian dates for March and put those in the Fiscal March Folder "06-Mar" , April into the April folder "07-Apr" and so on...so Fiscal reconciliations by month can then take place.. TIA for any help anyone can offer to expedite this time consuming hunt and picking process. =-)
  • To post as a guest, your comment is unpublished.
    Fer · 2 years ago
    en el codigo que copia ¿como puedo colorear el nombre de la lista que no encuentre?
  • To post as a guest, your comment is unpublished.
    Johnette · 2 years ago
    I cannot get either version to work in Windows 10.


    Argggg
  • To post as a guest, your comment is unpublished.
    Andy · 3 years ago
    Any tips on how to modify the code to add a wide card? I have an archive of hundreds of PDF files that are 10 digit numbers and revision level (XXXXXXXXXX_REVA). I can export a list of file names very easily from our ERP system, but the list is missing the revision and file extension. Is there a way to add wild cards into the program to ignore everything BUT the 10 digit number?
  • To post as a guest, your comment is unpublished.
    PWD · 3 years ago
    Hello,
    how to make this code copy files from subfolders?
  • To post as a guest, your comment is unpublished.
    Gokury · 3 years ago
    Hi Guys,

    How I need to change '' If TypeName(xVal) = "String" And xVal <> "" Then '' to move files based on partial file name.


    Thanks in advance,
    Best regards, P
    • To post as a guest, your comment is unpublished.
      technicallyspecific@gmail.com · 2 years ago
      Did you ever find out HOW to use a PARTIAL FILE NAME? I need that as well...
      In other words, if file name on the Excel sheet list is: OW4234TR_J19031.txt (I'd like it to only look at last 5 chars "19031" which is a Julian Date and move a range of files... anything with a Julian Date of 19031 thru 19075..
      • To post as a guest, your comment is unpublished.
        eric · 2 years ago
        I also would require the partial file name vba modification. Did you ever get a response?
        • To post as a guest, your comment is unpublished.
          Alexandru Matei · 1 years ago
          I am interested in exactly the same solution! Did anyone get the answer?
          I have a P/N list in a column, and I want a piece of code that looks in a parent folder that has several subfolders after files with the name indicated by the list, but only partially, because I don't know the file extension and in many cases for a single P/N in the list, I have several files differentiated by the existence of a suffix that does not always have the same pattern, such as xxxx_1, xxxx_2, xxx (1), xxxx [1], xxxx- (a ), xxxx_ (b) ...., but I need to copy in the destination folder, all the instances of the files that contain in their name the P/N.
          Please help me to not do this job manually for 34078 files that today finds in parent folder and subfolders
  • To post as a guest, your comment is unpublished.
    Sidney · 3 years ago
    Você não tem noção de como me ajudou com esse script... Muito bom!!! Obrigado!!!
  • To post as a guest, your comment is unpublished.
    Robinson · 3 years ago
    Obrigado!!!!
  • To post as a guest, your comment is unpublished.
    Alisson · 3 years ago
    Era exatamente isso que eu precisava!!!

    Muito Obrigado!!!!
  • To post as a guest, your comment is unpublished.
    Raki · 4 years ago
    Hi, In the source folder, I wish to set it as a constant from a cell, for example the path entered in a particular cell, like A1, should be treated as the source folder. How to do this?
  • To post as a guest, your comment is unpublished.
    madhan · 4 years ago
    It is the nice macro.Real helpful for me. but I need some update macro.this used to copy the files from single folder to another folder. we need copy files from folder and subfolder to another folder.