Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-18-2020, 11:54 AM
nmkhan3010 nmkhan3010 is offline Folder reorganizing Windows 10 Folder reorganizing Office 2016
Novice
Folder reorganizing
 
Join Date: Feb 2020
Posts: 23
nmkhan3010 is on a distinguished road
Default Folder reorganizing

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….
Attached Images
File Type: jpg Source.JPG (66.7 KB, 16 views)
File Type: jpg Output.JPG (120.0 KB, 16 views)
Reply With Quote
  #2  
Old 04-18-2020, 04:16 PM
macropod's Avatar
macropod macropod is online now Folder reorganizing Windows 7 64bit Folder reorganizing Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 04-18-2020, 10:32 PM
nmkhan3010 nmkhan3010 is offline Folder reorganizing Windows 10 Folder reorganizing Office 2016
Novice
Folder reorganizing
 
Join Date: Feb 2020
Posts: 23
nmkhan3010 is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 04-18-2020, 10:36 PM
macropod's Avatar
macropod macropod is online now Folder reorganizing Windows 7 64bit Folder reorganizing Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft