+ Reply to Thread
Results 1 to 11 of 11

Rename files in a single folder based on the modified date and words for each file

  1. #1
    Forum Contributor
    Join Date
    09-21-2022
    Location
    africa
    MS-Off Ver
    2019
    Posts
    182

    Rename files in a single folder based on the modified date and words for each file

    Hello guys
    I have many files in one folder
    All files contain the word sales reports. What I want is to rename the files inside the folder
    The files will be named using the modified date property
    For example :
    1- Mark sales report trading
    2- Brand Mark sales report for selling
    3-Total sales report monthly

    1-Mark sales report trading 10 DEC 2022
    2- Brand Mark sales report for selling 11 JAN 2023
    3-Total sales report monthly 03 FEB 2023

    In this case should add the day, month name, and year will be added as a suffix to each file based on the modified date for each file, taking into account that sales reports words must be present, otherwise the files that have these words will only be named and the files that do not contain these words will be ignored.
    The macro will run from within the folder so there is no need to give the folder directory
    thanks
    Last edited by Maklil; 03-07-2023 at 09:15 AM.

  2. #2
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Win 11)
    Posts
    3,331

    Re: Rename files in a single folder based on the modified date and words for each file

    Something along these lines, maybe.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    09-21-2022
    Location
    africa
    MS-Off Ver
    2019
    Posts
    182

    Re: Rename files in a single folder based on the modified date and words for each file

    thanks it works as I expected, but there is problem when there are files names have already renamed containing dd mmm yyyy , then will continue add dd mmm yyyy
    should just rename for doesn't contain dd mmm yyyy . could you fix it ,please?

  4. #4
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Win 11)
    Posts
    3,331

    Re: Rename files in a single folder based on the modified date and words for each file

    Please try it like this.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    09-21-2022
    Location
    africa
    MS-Off Ver
    2019
    Posts
    182

    Re: Rename files in a single folder based on the modified date and words for each file

    unfortunately still add dd mmm yyyy continuously when run the macro every time

  6. #6
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Win 11)
    Posts
    3,331

    Re: Rename files in a single folder based on the modified date and words for each file

    unfortunately still add dd mmm yyyy continuously when run the macro every time
    Not sure.
    If it test it on a file Test Sales Reports.txt
    Running the first time changes it to Test Sales Reports 08 MAR 2023.txt
    Subsequent runs have no effect.

    You could try using this line which looks for the date anywhere in the file name.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    09-21-2022
    Location
    africa
    MS-Off Ver
    2019
    Posts
    182

    Re: Rename files in a single folder based on the modified date and words for each file

    still the same problem.
    did you test with EXCEL files?

  8. #8
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Win 11)
    Posts
    3,331

    Re: Rename files in a single folder based on the modified date and words for each file

    Yes, on a mix of file types.
    Is it possible to post an actual file name?

  9. #9
    Forum Contributor
    Join Date
    09-21-2022
    Location
    africa
    MS-Off Ver
    2019
    Posts
    182

    Re: Rename files in a single folder based on the modified date and words for each file

    OK
    BTW: you have typo should not reports , should be report .
    any way I modified based on your code.
    Attached Files Attached Files

  10. #10
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Win 11)
    Posts
    3,331

    Re: Rename files in a single folder based on the modified date and words for each file

    Thanks for pointing that out. I don't think it's related to your issue though, as "reports" would have meant that files with "report" would have been over looked.
    I'm still not getting the date added more than once.

  11. #11
    Forum Contributor
    Join Date
    09-21-2022
    Location
    africa
    MS-Off Ver
    2019
    Posts
    182

    Re: Rename files in a single folder based on the modified date and words for each file

    I don't think it's related to your issue though, as "reports" would have meant that files with "report" would have been over looked.
    yes that's correct ,but if the others members especially the beginners read OP ,then your code doesn't work .
    I'm still not getting the date added more than once.
    I'm still lost why does that for me !

+ 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. [SOLVED] Count files in a folder that have a certain date modified range
    By KColgrove in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2019, 12:21 PM
  2. Pull Date Modified from file folder
    By KColgrove in forum Excel General
    Replies: 1
    Last Post: 05-22-2019, 11:46 PM
  3. Replies: 18
    Last Post: 11-27-2018, 05:25 AM
  4. Replies: 0
    Last Post: 01-21-2014, 10:52 AM
  5. [SOLVED] How to put Prefix in filenames on all files in folder with Modified Date
    By junmishima in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-26-2013, 08:47 PM
  6. open the newest excel file in a folder based on modified date
    By dulitul in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2013, 12:52 PM
  7. Rename Files in Folder - Change Date Format
    By karma4910 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2011, 05:24 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