+ Reply to Thread
Results 1 to 7 of 7

Rename files and store them at different paths.

  1. #1
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Rename files and store them at different paths.

    Hello.

    Does anyone know the coding or if it is possible to make a code which renames files and store them in different paths?

    Example:

    I want the file EXCELtestYYYYDDMM.txt to be named only testYYYYDD-1MM.txt.
    The original file will have the date of today, but the renamed file will have yesterdays date, except on mondays (then it would have to be the last friday).

    And then stored in a different path than the original one.

    The files would be *.txt *.pos and *.sen

    Thanks in advance.

  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: Rename files and store them at different paths.

    Try this:
    Please Login or Register  to view this content.
    _________________
    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
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Smile Re: Rename files and store them at different paths.

    You are good!

    If possible, are you able to do some adjustments?
    - I want to keep the original file.
    - I only want the macro to do the file made today. So that I can keep the older files in the same folder.

    And a separate macro which copies these files onto different locations.

    Thank you so much. It will help me a lot

  4. #4
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Rename files and store them at different paths.

    And now it also changes any file in the folder with a date format, I would like to have it change only the files with a certain start like:
    PERFEECTtestYYYYDDMM.txt to testYYYYDDMM.txt

  5. #5
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Rename files and store them at different paths.

    And if you could be so kind to design a third macro as well:

    This macro should be able to take the generated *.txt files and melt them into one textfile with a new name.

    So that

    test1YYYYDDMM.txt
    test2YYYYDDMM.txt
    test3YYYYDDMM.txt

    becomes

    finalYYYYDDMM.txt

    and the date on the test files should be yesterdays date except on mondays (then the last friday).

  6. #6
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Rename files and store them at different paths.

    Do you know how to fix this? The dateformat on the text files needs to be:
    YYMMDD,

    and on pos and sen: YYYYMMDD

    How can I juggle between the formats?

    Thank you!

  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: Rename files and store them at different paths.

    Can you look at the macro and spot where the date format is controlled? It pretty much jumps out at you.
    Please Login or Register  to view this content.


    I suppose you could add an IF/THEN to that:
    Please Login or Register  to view this content.

+ 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