+ Reply to Thread
Results 1 to 7 of 7

Move files from one folder to several others dependent on File name

  1. #1
    Registered User
    Join Date
    06-17-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    3

    Move files from one folder to several others dependent on File name

    Hi, I've had a search on a lot of forums butI can't work out how to adapt the code I've found to my problem.

    I have set up a button on a Worksheet which needs to initiate the moving of a number of files from one folder to several others.
    The source folder path is ‘C: \Audits to be sent’.

    There are 2 different types of Excel file:
    Level A Audit
    B Audit
    These will be moved to other folders dependant on the file name.

    The target folders are:
    ‘C:\Reporting\Audit files\Level A Audits’
    'C:\Reporting\Audit files\Level B Audits\Level B Year 14\Level B 1403’
    (The Level B Year folder is dependent on the first 2 numbers (14) of the file and of course the 4 digits (1403) indicates which folder in there)

    Example File names:
    Level A Audit at Location for Period 1401.xls
    B Audit Location14_01.xls

    There shouldn't be any duplicate files but how would it handle those?
    So to summarise, the function would search the ‘Audits to be sent’ folder move all of the Level A files to the ‘Level A Audits’ folder. Then it would in turn look at the Level B Audits, ascertain their individual Year Folder and then move it to the correct Period Folder.

    Thank you for any help that you can give me.

    James

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Move files from one folder to several others dependent on File name

    Please explain more fully with examples of filenames that resolve to Level A, and filenames that resolve to Level B. The logic needs to be straightfoward and work on every file name encountered.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    06-17-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Move files from one folder to several others dependent on File name

    Hi, thanks for having a look into my problem. The 2 elements that change are the location, location1, location2 etc and the period number, 1401, 1402 (to 1413 then 1501 etc).

    I hope this all makes sense.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Move files from one folder to several others dependent on File name

    No, you provided additional information without explaining what each value means in terms of where is would be copied.

    Pretend you have to explain it once and then someone has to decide where to copy EVERY FILENAME encountered after that based on what you tell, you can't leave any detail out.

  5. #5
    Registered User
    Join Date
    06-17-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Move files from one folder to several others dependent on File name

    Ok, to put it plainly:

    More Example file Names:
    Level A Audit at Location(1) for Period 1401.xls move to … Audit files\Level A Audits
    Level A Audit at Location(2) for Period 1401.xls move to … Audit files\Level A Audits
    Level A Audit at Location(2) for Period 1402.xls move to … Audit files\Level A Audits
    Level A Audit at Location(3) for Period 1513.xls move to … Audit files\Level A Audits
    So if 'Level A' appears at the beginning of the file name place it in the Level A audits folder, no matter what the period number is.

    B Audit Location(1)14_01.xls move to … Audit files\Level B Audits\Level B Year 14\Level B 1401
    B Audit Location(1)14_02.xls move to … Audit files\Level B Audits\Level B Year 14\Level B 1402
    B Audit Location(2)14_01.xls move to … Audit files\Level B Audits\Level B Year 14\Level B 1401
    B Audit Location(3)15_01.xls move to … Audit files\Level B Audits\Level B Year 15\Level B 1501
    B Audit Location(1)15_03.xls move to … Audit files\Level B Audits\Level B Year 15\Level B 1503
    If 'B Audit' appears then the first part of the Period number, for example '14_', determines which year folder, this example 'Audit files\Level B Audits\Level B Year 14', and the last part of the period number, example '_01' determines the sub folder, example 'Audit files\Level B Audits\Level B Year 14\Level B 1401'.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Move files from one folder to several others dependent on File name

    Untested...

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 06-18-2013 at 11:21 AM. Reason: correction to fPATHtoB

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Move files from one folder to several others dependent on File name

    Thanks for the feedback/rep.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
    Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1