Results 1 to 14 of 14
  1. #1
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,423
    Thanks
    125
    Thanked 5 Times in 5 Posts

    Move Files from one folder to another based on date

    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
    Attached Files Attached Files

  2. #2
    5 Star Lounger Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    627
    Thanks
    168
    Thanked 77 Times in 68 Posts
    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?

  3. #3
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,832
    Thanks
    136
    Thanked 484 Times in 461 Posts
    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

  4. #4
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,423
    Thanks
    125
    Thanked 5 Times in 5 Posts
    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
    Attached Images Attached Images
    Last edited by HowardC; 2015-11-01 at 05:34.

  5. #5
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,423
    Thanks
    125
    Thanked 5 Times in 5 Posts
    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
    Attached Images Attached Images

  6. #6
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,423
    Thanks
    125
    Thanked 5 Times in 5 Posts
    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

  7. #7
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,832
    Thanks
    136
    Thanked 484 Times in 461 Posts
    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

  8. #8
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,423
    Thanks
    125
    Thanked 5 Times in 5 Posts
    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

  9. #9
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,832
    Thanks
    136
    Thanked 484 Times in 461 Posts
    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

  10. #10
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,423
    Thanks
    125
    Thanked 5 Times in 5 Posts
    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
    Attached Files Attached Files

  11. #11
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,832
    Thanks
    136
    Thanked 484 Times in 461 Posts
    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
    Attached Files Attached Files

  12. The Following User Says Thank You to zeddy For This Useful Post:

    HowardC (2015-12-21)

  13. #12
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,423
    Thanks
    125
    Thanked 5 Times in 5 Posts
    Thanks very Zeddy-the updated workbook, works perfectly

  14. #13
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,832
    Thanks
    136
    Thanked 484 Times in 461 Posts
    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)

  15. #14
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,423
    Thanks
    125
    Thanked 5 Times in 5 Posts
    Thanks for the explanation

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •