+ Reply to Thread
Results 1 to 14 of 14

Macro to list files then Rename them

  1. #1
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Macro to list files then Rename them

    hi all

    i need your help plz, i am trying to find macro to list all files in specific folder in column A, what ever i put in column will be the new name of the file

    example;

    Cell A2 = New.mp4
    Cell B2 = ggffrr.mp4

    i want it because i have thousands of file and i think that this is the only way as i want to review all names

    thanks

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Macro to list files then Rename them

    Hi, this should be what you need.
    When run a dialogue box will apear to selct the folder you want.
    then it will pass all the file in the folder to column A

    Please Login or Register  to view this content.
    Code copied from http://mariaevert.dk/vba/?p=99
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  3. #3
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: Macro to list files then Rename them

    hi sean

    after i select the folder nothing happened, also the code i think will list the files in folder, but ow about the renaming?

    thanks.

  4. #4
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Macro to list files then Rename them

    Hi, it works fine for me.
    the browser will open, select the folder you want, open it and then click ok.
    It will then pass every file name into column A.

    Sorry i dont understand the part about renaming them
    you will need to be clearer on what you require.

  5. #5
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: Macro to list files then Rename them

    i dont know why your code is not working; Ok let me explain, forget about the macro to list all files in the folder; lets say i already list all files in the folder in column A, i will write the new name in column B then i want macro to take the new name in column B to rename the fie name it self

    example;
    Cell A2 = New.mp4
    Cell B2 = ggffrr.mp4

    thanks
    Last edited by boss1982; 10-30-2013 at 11:56 AM.

  6. #6
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: Macro to list files then Rename them

    ok i found the following code from another topic, but the only two problems that after i run the rename macro will open for me to select the folder;

    1- it will cut the original file
    2- it will change the name and paste the files on desktop

    anyone can help me to modify the code to keep the files in the same location?

    thanks

    HTML Code: 
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: Macro to list files then Rename them


  8. #8
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Macro to list files then Rename them

    Hi, i just tried the above code and it worked fine for me.
    How are you renaming the files?
    i have attached screen shot of what worked for me.

    When it renamed them it did not change the location
    Attached Images Attached Images

  9. #9
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: Macro to list files then Rename them

    hi

    sorry about my late reply, was very busy, actually i still have problem, the code is working perfectly but still i have the problem which i post in post#6

    any one can have a look to the 2nd code which is "Sub Rename_Files()"

    if i run the renaming macro will pop up to me to browse where i want to put the new files;
    1- if choose new location / new folder...nothing will happened.
    2- if i choose the same old location....the macro will work but it will move the files to desktop.

    what i want is to rename the files and to copy them to the new folder i choose without touching the old folder / old files

    thanks
    Last edited by boss1982; 03-24-2014 at 05:03 AM.

  10. #10
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: Macro to list files then Rename them


  11. #11
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: Macro to list files then Rename them

    ok to make everything easier; i did another code (some i coded and some from Google) and i attach it with the excel....and also the same problem.

    now no need to copy the files first...just rename and to keep in the same folder, it is working fine but the location will be always desktop or documents location

    i need it rename and to keep the files in the same location

    please help
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: Macro to list files then Rename them

    any help please for editing the code?

  13. #13
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Macro to list files then Rename them

    The rename code from the file in post# 11 didn't work for me either. I had to adjust it to what you see below. The adjusted code I'm posting here works for me. See if it works for you.
    If so, please mark this as solved and click the star below. Thanks!
    Please Login or Register  to view this content.
    If I helped in any way, please click the star

  14. #14
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: Macro to list files then Rename them

    ok i got the code from another source...thanks a lot....closed

+ 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. Replies: 0
    Last Post: 03-04-2013, 02:37 PM
  2. Rename files with a macro
    By bensalisbury in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2012, 07:42 AM
  3. Copy files from list and rename
    By uncleslinky in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-27-2011, 07:53 AM
  4. Rename files based on excel worksheet list
    By badgeradrian in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2009, 05:52 PM
  5. Want to rename files in Excel using a list
    By runnershane14 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-27-2007, 11:44 AM

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