+ Reply to Thread
Results 1 to 3 of 3

Ability to rename multiple files from a path and move and rename to another.

  1. #1
    Forum Contributor
    Join Date
    08-23-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    128

    Ability to rename multiple files from a path and move and rename to another.

    I have been given a folder of over 1760 files. These are inside multiple directories.

    I managed to make a file of all the filenames and paths. But I'm hoping excel can help with the renaming.

    My idea is to enter the original path and name in one cell and its new name and location in another, in 1700 rows and let it run.

    I've found some renaming scripts, but none I've found deal with subfolders. In most cases I need to make the subfolder first myself and that would be tedious.

    Anyone have any ideas where to start?

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,987

    Re: Ability to rename multiple files from a path and move and rename to another.

    Might this not be easier using Windows command line code?

    https://stackoverflow.com/questions/...der-to-another
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Ability to rename multiple files from a path and move and rename to another.

    Quote Originally Posted by X82 View Post
    Anyone have any ideas where to start?
    It sounds like you know how to run code to list all the files & folders. That's a good start.

    Here's a rushed outline of how I would approach this
    1. Run your file/folder listing code and output to an array
    2. Clone this array (henceforth the original is Source array and the clone will be called Dest array)
    3. loop through the Dest array to rename to desired destinations. (I'm assuming you have some renaming logic you want to apply i.e. You don't intend to have custom destinations for all 1760 files)
    4. Loop through the Dest array again. In each loop extract the path component from the dest fullname. Run function to see if this path exists. If not, use MkDir to create this path. NB that if this path contains subfolders, you need to make each subfolder in order.
    5. Now loop the Source array and use Name [source fullname] As [dest fullname] (obtain Dest fullname from the same index location in the Dest array)

    There are other ways of doing this. Above is but one approach that will get the job done. There could be some speed improvements made in above but if we are only talking 1760 files, this isn't really a concern.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Rename and move files to a prespecified location
    By Chrysanthiiiiii in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-09-2019, 11:45 AM
  2. VBA code to open some pdf files and rename it in a different path
    By Frank_smera in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2018, 11:23 AM
  3. My File Rename Macro Always Doesn't Rename the Last Three files in the list
    By Enright in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-02-2016, 03:46 PM
  4. Excel to move and rename files
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2012, 07:01 PM
  5. [SOLVED] Move, Rename all files from a folder
    By kinseld5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-26-2012, 12:20 PM
  6. Replies: 1
    Last Post: 10-06-2008, 10:29 PM
  7. Macro to rename and move files
    By Caroline25 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-15-2007, 03:11 PM

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