+ Reply to Thread
Results 1 to 12 of 12

Rename and Replace File names

  1. #1
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Rename and Replace File names

    Good afternoon to one and all


    Over the last couple of weeks I have been lucky enough to enlist the aid of Jindon and Mohan1980 with some codes, that section is now completed, and on advise of a forum Admin I wish to start a new thread.

    I have a EXCEL spreadsheet that looks at 27 different .CSV files and one of the files is the device_details.csv the codes that have been written for me extract certain data from this 200+ Meg file, the first of these 2 codes generates a file call " device_details_RK#R.csv". then the second code then generates a file called "device_details_RK#R_Extract.csv"

    Once all these 2 codes have run what would like to do if possible is to rename the original source file "device_details.csv" to say eg: "device_details_org.csv" then rename "device_details_RK#R_Extract.csv" to "device_details.csv".

    I will attach a cut down version of "device_details_RK#R_Extract.csv" file also the second code.

    Any assistance will be truly appreciated, Thank You in advance

    Peter


    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Rename and Replace File names

    Try:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Re: Rename and Replace File names

    Good evening Kaper

    Thank you for your reply

    When I run this code
    Please Login or Register  to view this content.
    I get an error message on the first line highlighted in yellow.


    If it is of any help just to clarify

    In the directory I have the following files

    "device_details.csv"
    "device_details_RK#R.csv"
    "device_details_RK#R_Extract.csv"


    It is the "device_details.csv" saved as "device_details_ORG.csv"

    and the "device_details_RK#R_Extract.csv" saved as "device_details.csv"



    Peter
    Last edited by Potholes; 07-13-2018 at 05:36 AM. Reason: Amended Details

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Rename and Replace File names

    OK, so let's see if filenames and paths are assigned properly.
    Please Login or Register  to view this content.
    The next point is may be there already exists "device_details_org.csv" in the folder? if yes, then of course rename will fail here, old versin of _org shall be deleted first (for instance with
    Please Login or Register  to view this content.
    PS. Still Good Morning here :-) (11:49 AM)

  5. #5
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Re: Rename and Replace File names

    Hi

    I an getting a message box which is confusing me ATM, when I run the code and it is NOT renaming


    "device_details.csv" <<<<<<<<<<<<<<<<<<<<<<<<<<<< To "device_details_ORG.csv"
    "device_details_RK#R.csv" <<<<<<<<<<<<< Leave alone naming wise
    "device_details_RK#R_Extract.csv"<<<<<<<<<<<<<<<<<<<<<<<<<<<< To "device_details.csv"


    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Rename and Replace File names

    May be

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Re: Rename and Replace File names

    Good evening sir

    Is it possible to remove the popup box showing what is what files should be.

  8. #8
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Rename and Replace File names

    Hi Peter,

    Is it possible to remove the popup box showing what is what files should be.
    are you try #6??

  9. #9
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Re: Rename and Replace File names

    This is my entire code


    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Rename and Replace File names

    Hi Peter

    Delete below line from your code

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Re: Rename and Replace File names

    Thank you

    Off to bed now TTFN

    Thanks to you and Kaper

  12. #12
    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,910

    Re: Rename and Replace File names

    For the benefit of those who don't understand, TTFN means "ta ta (goodbye) for now".
    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.

+ 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. Extracting attachments and rename file names
    By koltregaskes in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 09-15-2017, 03:07 PM
  2. 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
  3. [SOLVED] To find the Special charcter and space of the file names and replace with the underscore
    By laxmanann in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-14-2014, 09:31 AM
  4. Excel VBA find and replace string in non text file and rename file
    By razzack in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-01-2013, 02:43 PM
  5. Rename File Names & Repost to Designated Folder
    By Surfmaster in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2012, 01:45 PM
  6. Pull File Names into Excel and replace dir
    By SteelJ0ke in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-08-2011, 10:43 AM
  7. can I save a file of multiple names to replace using excell 03
    By Greg is working hard. in forum Excel General
    Replies: 2
    Last Post: 07-18-2006, 08:45 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