Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is it possible to move files based on the date stamp of the file(s)?

    I have a number of files that I would like to move (based on dates) to an archieve.

    As an example: Move *.xls with a date stamp <= April 30, 2009


    Thanks,
    John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    How does this relate to "Web Design, Coding and Scripting"?

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I thought about putting it under Windows XP but then "Coding" sort of jumped out at me.

    Feel free to move it.

    Regards,
    John


    [quote name='jstevens' post='777902' date='01-Jun-2009 15:47']Is it possible to move files based on the date stamp of the file(s)?

    I have a number of files that I would like to move (based on dates) to an archieve.

    As an example: Move *.xls with a date stamp <= April 30, 2009


    Thanks,
    John[/quote]

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    OK, I'll move it to Windows XP. Hopefully BATcher will know how to do this.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Do you actually need to use a batch file, or could you use VBScript or VBA code too?

  6. #6
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hans,

    I would prefer it to be in a "batch file' as the batch file can be schedule to run.

    Regards,
    John


    [quote name='HansV' post='777908' date='01-Jun-2009 16:00']OK, I'll move it to Windows XP. Hopefully BATcher will know how to do this.[/quote]

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Apparently date arithmetic in a batch file is rather complicated. There's an example on Experts Exchange: do a Google search for move files older than date site:experts-exchange.com, and click the result Move files older than "X" days based on date stamp. Don't be put off by all the warnings that you need to sign up. Scroll almost all the way down until you see the "accepted solution" by pbarrette.

  8. #8
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Hans,

    I found the post and will have to give it a try.

    Regards,
    John

    [quote name='jstevens' post='777913' date='01-Jun-2009 16:25']Hans,

    I would prefer it to be in a "batch file' as the batch file can be schedule to run.

    Regards,
    John[/quote]

  9. #9
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,417
    Thanks
    33
    Thanked 195 Times in 175 Posts
    [quote name='jstevens' post='777902' date='01-Jun-2009 23:47']Is it possible to move files based on the date stamp of the file(s)?
    I have a number of files that I would like to move (based on dates) to an archieve.
    As an example: Move *.xls with a date stamp <= April 30, 2009[/quote]
    I don't know how far you've got, but with BATch files you have to be very precise about what you want to achieve. I would have a whole bunch of questions, about directory and file names, what happens if the file already exists in the target directory, and so on and so forth.
    As Hans says, date arithmetic is rather messy, but it's quite possible. I usually look at, and often use, Ritchie Lawrence's Date and Time Functions in his Batch function library, and at the BATch file FAQ. The approach I'd take is to determine each file date as the number of days since some arbitrary startpoint (say 01/01/2000 - assuming there are no older files!) and compare each with the day number of the date you want.
    By the way. MOVE is one of the worst 'DOS commands' - I tend to use COPY old to new, then DELete old if the copy is successful.
    BATcher

    Time prevents everything happening all at once...

  10. #10
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='jstevens' post='777902' date='02-Jun-2009 08:47']Is it possible to move files based on the date stamp of the file(s)?

    I have a number of files that I would like to move (based on dates) to an archieve.

    As an example: Move *.xls with a date stamp <= April 30, 2009


    Thanks,
    John[/quote]
    Might be worth looking at using XXCOPY, a Versatile File Management Utility --- Boldly Extended Xcopy. XXCOPY in batch files gives some example usage.

    Alan

  11. #11
    Star Lounger
    Join Date
    Feb 2009
    Location
    Evanston, Illinois, USA
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The following two batch file commands might do an effective xls file move:

    1st command by Xcopying and pasting xls files, from June 1st 2009 and later, to a new directory -

    2nd command by deleting xls files from the old directory with a Y or N prompt.

    ================================================

    Xcopy/s/y/d:06/01/2009 C:\OLDDIR\*.xls C:\NEWDIR\June\*.*

    Del/s/f/p C:\OLDDIR\*.xls

    ================================================

    Ted Kruzich

  12. #12
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='jstevens' post='777902' date='01-Jun-2009 19:47']Is it possible to move files based on the date stamp of the file(s)?[/quote]
    I swear by RoboCopy.

  13. #13
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Chris,

    Thankyou for the suggestion. I'm a happy camper...

    John
    [quote name='chrisgreaves' post='779149' date='10-Jun-2009 10:00']I swear by RoboCopy.[/quote]

  14. #14
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Chris,

    Do you know of a GUI calendar interface (free) that I can incorporate into the batch file. This is what I am trying to achieve:

    1. Open GUI calendar
    2. Select appropriate YYYYMMDD
    3. Pass this variable (in item #2) to the batch file
    4. Process batch file

    Thanks,
    John

  15. #15
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found what I was looking for here in the Lounge.

    Regards,
    John

Page 1 of 2 12 LastLast

Posting Permissions

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