• Move Files from one folder to another based on date

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Move Files from one folder to another based on date

    Author
    Topic
    #502916

    I have a macro and workbook developed by Zeddy to move files from one folder to another prior to a certain date

    For eg moving all csv files prior to 30/09/2015

    When running the macro the csv files prior to the date set in this instance 30/09/2015 have not moved

    It would me appreciated if Zeddy or someone can assist me

    Viewing 4 reply threads
    Author
    Replies
    • #1535251

      Is it possible you need to use the USA date format MDY, ie 9/30/2015, instead of the much more common world format DMY, when specifying the date?

      Lugh.
      ~
      Alienware Aurora R6; Win10 Home x64 1803; Office 365 x32
      i7-7700; GeForce GTX 1060; 16GB DDR4 2400; 1TB SSD, 256GB SSD, 4TB HD

      • #1535256

        Hi Lugh

        You raise a good point about the dates.
        However, I took this into account in the ‘move-file-tool’ by including a ‘calendar’ button to let the User select the date from a calendar. There can be no confusion with dates when selecting from this calendar. It will work regardless of the local date format.
        If you download the file posted by Howard, you will see this.

        Howard:
        If you look carefully at your posted file, you will see that you have chosen to ‘move’ csv files dated earlier than the selected date of ’30 September 2015′. In your chosen source folder, the source files matching the selected csv file type, are files all dated AFTER ’30 September 2015′. This is clearly shown in the FileDateStamp in column [C] of the matching files in the source folder. Hence the status of ‘kept’ rather than ‘moved’.
        Perhaps you should change your ‘move-files-earlier-than’ date??????

        So, nothing wrong with tool as far as I can see!

        zeddy

        • #1535259

          Hi Zeddy

          Thanks for getting back to me

          I have a csv file dated 02/07/2015 that does not appear on the list under files when selection 30 Sept 2015. For some unknown reason, it cannot find this csv file

          Please test & advise-have attached screen

        • #1535261

          Hi Zeddy

          If file to be moved, already exists in the destination folder already exists, it can be over-written. Kindly amend your code to take this into account

          Also why would a csv file appear as “problem” under status -see screen print

          • #1535482

            Hi Zeddy

            Have you had a chance to have a look at my post # 4 & # 5? It would be appreciated if you would kindly have a look when you have a chance and amend your code accordingly

            Howard

    • #1535612

      Hi Howard

      I see that the file reported in post#4 now appears in the list of files in post#5, but shows as problem! in the status column.

      1. If a file you are expecting to see doesn’t appear in the folder list, click the [Clear File List..] button (as shown just above the filename column in your post#5 screenshot), and then re-select the folder.

      2. There are many reasons why a file being ‘processed’ may trigger a problem. It could be that the file is currently ‘open’ by another User, or the file is ‘locked’ by the system, or the file isn’t really a csv file (just because it has a csv file extension doesn’t guarantee that the file is actually of that type). It could also be a ‘corrupt’ file.

      If you really wanted to have a more detailed fault description, you could search the vba code and replace the section where ‘problem!’ is used and include new code for the Err.Description etc etc etc.
      The status ‘problem!’ is reported simply to allow you to investigate the issue directly, like trying to open the file directly etc etc etc.

      I am running late for preparing for my departure early Thursday. It’s a two-month mission so I’ve got lots to do.
      I recently posted a processing file for copying files to another folder, which included an ‘overwrite’ option for the destination folder.
      Perhaps this could be used to adapt the ‘move files’ version in post#1.
      I will post an updated version myself, but it will be a few days before I get set up abroad.

      zeddy

    • #1535692

      Thanks Zeddy for the reply and your explanations

      I will have a look at your recent post for processing a file for copying files to another folder, which included an ‘overwrite’ option for the destination folder, to see if I can adapt the code.

      I will keep you posted.

      Hope you have a good and successful trip

      • #1535708

        Hi Howard

        ..if you get stuck, just post back here and I’m sure one of the many able helpers here will assist.
        I shall also work on it after I get my equipment set up in the next few days.

        zeddy

    • #1535715

      Hi Zeddy

      Hope you have a safe trip and that the project is successful. Thanks very much for all your help

      I have tried to make some changes , but cannot get the macro the work. The status of the filenames now appears as missing. When you get the change, it would be appreciated if you can have a look at this, but there is no rush

      Howard

      • #1543059

        Hi Howard

        Please see updated file attached.

        For matching Files that have datestamps prior to your chosen cutoff date:
        If a file with the same name already exists in the specified destination folder, and you have selected not to overwrite (i.e. the chosen overwrite setting is False), then the status will be ‘overwrite disallowed’.

        zeddy

        • #1543094

          Thanks very Zeddy-the updated workbook, works perfectly

          • #1543122

            Hi Howard

            Thanks for letting me know.

            Just to recap, these are the STATUS values:
            STATUS:
            kept ;file datestamp is later than chosen date
            moved ;file moved to destination folder
            moved and overwritten ;file moved and replaces existing file
            overwrite disallowed ;file NOT moved as already exists in destination folder
            missing! ;file has been deleted or moved, since start of this process
            problem! ;e.g. file may be currently open or locked by system

            Have a great Christmas.
            I will be up to my neck in it in the Caribbean for my last week

            zeddy
            (..that’s in the sea of course)

    • #1543157

      Thanks for the explanation

      Hope you have a great Christmas and enjoy your time in the Caribbean

    Viewing 4 reply threads
    Reply To: Reply #1535482 in Move Files from one folder to another based on date

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel