![]() |
#1
|
|||
|
|||
![]()
In a folder am having N no of documents and all the file names will have 3 common names followed as “-ConvetedTables” “- EnglishTables” “-NativeTables_Translated” I want to move the files tagged with “-ConvetedTables” to “Converted folder” and “- EnglishTables” to “EnglishTables” folder and “-NativeTables_Translated” to “NativeTables_Translated” folder.
I need a macro for this can anyone help me… A folder has to create in the same path with the names (ConvetedTables, EnglishTables, NativeTables_Translated) and move all the files to the respective folders tagged with the names as -ConvetedTables, -EnglishTables, -NativeTables_Translated For every file name first eight digits are numbers only, it is fixed for every file, and documents formats “.doc” “.docx” “.pdf” Your help will be highly appreciated…. Please find attachments for references…. |
#2
|
||||
|
||||
![]()
You don't need a macro for this. Simply:
1. Create the destination folders 2. Sort the files by name; 3. Drag the sorted files to their respective folders. It would take longer to write the macro than doing it manually.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Thanks for your prompt response....
Am gaining more productivity with your help.... ![]() Currently am doing the same practices but somewhere it is missing and copying wrong files into the folder and again re-checking where it has been missed taking more time and that this is happened due to more no. of files in folder (200+ files) and it is difficult to handle at a time. So am trying for the perfection in this ….. Am having the below code, can you modify according to my need.... Thanks in advance…. Code:
Sub FolderizeFiles() Dim fso As Object, fldr As Object, subFldr As Object, fle As Object Dim fldrNew As String Set fso = CreateObject("Scripting.FileSystemObject") Set fldr = fso.GetFolder("C:\Users\xuza\test") For Each fle In fldr.Files If Right(fso.GetBaseName(fle), 14) = "-EnglishTables" Then fldrNew = fldr.Path & "\" & fso.GetBaseName(fle) If Not fso.FolderExists(fldrNew) Then fso.CreateFolder fldrNew End If fso.MoveFile _ Source:=fle.Path, _ Destination:=fldrNew & "\" & fle.Name End If Next fle For Each fle In fldr.Files For Each subFldr In fldr.SubFolders If Left(subFldr.Name, 8) = Left(fle.Name, 8) Then fso.MoveFile _ Source:=fle.Path, _ Destination:=subFldr.Path & "\" & fle.Name Exit For End If Next subFldr Next fle End Sub |
#4
|
||||
|
||||
![]()
Really, if you sort the files as I suggested before moving them, it doesn't matter how many files there are and, unless you're careless, you shouldn't end up with any files in the wrong folder.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Create rule to move email from archive folder to senders name folder | bigduke70 | Outlook | 0 | 03-09-2019 08:33 AM |
Reorganizing (re-sorting) page numbers | PA/EA/Secretary | Word | 4 | 03-01-2019 06:43 AM |
Hilight Parent Folder when Child folder is allocated a new email | brucemc777 | Outlook | 2 | 11-09-2016 09:14 AM |
Linking to a spreadsheet in the same folder without folder path | Jacky837 | Excel | 0 | 07-30-2016 05:07 AM |
How to constantly and automatically copy the contacts from a shared folder to my private folder? | Paulo | Outlook | 0 | 08-16-2015 12:06 PM |