Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: /D:MM-DD-YYYY troubles .... for sorting data by year into folders  (Read 6805 times)

0 Members and 1 Guest are viewing this topic.

DaveLembke

    Topic Starter


    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Trying to group about 374GB of data created over the last 9 years at C:\data into folders by year. Problem I have is that the  xcopy /s/d:MM-DD-YYYY/y  "/D"switch will grab all data on or after the date specified, and I cant seem to create a range to only grab say 01-01-2008 to 12-31-2008, so I have to have it perform a clean up after xcopying the data to the destination that will remove this newer data  from the original source path so that the next xcopy routine can grab the next group of 01-01-2007 to 12-31-2007 data without passing the newer 2008 and 2009 data into the 2007 folder. ( Scratching my head on how to delete only this range of date/time stamped data after it is xcopied??? )

Below is an example of what I have so far, with explainations as to what I believe needs to happen in <   > between each xcopy /s/d:MM-DD-YYYY/y routine.

Run from C:

xcopy c:\data\*.*  c:\test1\2009\*.* /s/d:01-01-2009/y
<delete 2009 data so that next routine doesnt pass 2009 data to 2008. ???>
xcopy c:\data\*.*  c:\test1\2008\*.* /s/d:01-01-2008/y
<delete 2008 data so that next routine doesnt pass 2008 data to 2007. ???>
xcopy c:\data\*.*  c:\test1\2007\*.* /s/d:01-01-2007/y
<delete 2007 data so that next routine doesnt pass 2007 data to 2006. ???>
xcopy c:\data\*.*  c:\test1\2006\*.* /s/d:01-01-2006/y
<delete 2006 data so that next routine doesnt pass 2006 data to 2005. ???>
xcopy c:\data\*.*  c:\test1\2005\*.* /s/d:01-01-2005/y
<delete 2005 data so that next routine doesnt pass 2005 data to 2004. ???>
xcopy c:\data\*.*  c:\test1\2004\*.* /s/d:01-01-2004/y
<delete 2004 data so that next routine doesnt pass 2004 data to 2003. ???>
xcopy c:\data\*.*  c:\test1\2003\*.* /s/d:01-01-2003/y
<delete 2003 data so that next routine doesnt pass 2003 data to 2002. ???>
xcopy c:\data\*.*  c:\test1\2002\*.* /s/d:01-01-2002/y
<delete 2002 data so that next routine doesnt pass 2002 data to 2001. ???>
xcopy c:\data\*.*  c:\test1\2001\*.* /s/d:01-01-2001/y
<delete 2001 data so that next routine doesnt pass 2001 data to 2000. ???>
xcopy c:\data\*.*  c:\test1\2000\*.* /s/d:01-01-2000/y
rd data

This rd data is the final clean up to remove c:\data   after all data was moved into the grouped years with subdirectory data tree intact

Problem I have is how do you delete only data with date/time stamp of on say 01-01-2009 or after for each year to avoid the "/D:MM-DD-YYYY" passing newer data into what should be only the older specified directory path. I also want to keep the "/S" switch to maintain the directory path structure for data moved into the correct year of date/time stamp.

Any suggestions or code solutions vs the path I am taking with this project to group data by year?

I am guessing that there may be a better way and I am really butchering the purpose of the xcopy command by creating an individual instruction set for each year.

((OR)) can this be achieved without destroying the original C:\data source location to have the mixed data at c:\data and the sorted by year c:\test1\(year) locations by being able to set a date/time stamp range of 01-01-year to 12-31-year ??? ((if free space permitted!))

Thanks for your help in advance to the solution that you provide to my coding madness ...  ;D

Helpmeh



    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
Re: /D:MM-DD-YYYY troubles .... for sorting data by year into folders
« Reply #1 on: April 10, 2009, 04:09:09 PM »
Trying to group about 374GB of data created over the last 9 years at C:\data into folders by year. Problem I have is that the  xcopy /s/d:MM-DD-YYYY/y  "/D"switch will grab all data on or after the date specified, and I cant seem to create a range to only grab say 01-01-2008 to 12-31-2008, so I have to have it perform a clean up after xcopying the data to the destination that will remove this newer data  from the original source path so that the next xcopy routine can grab the next group of 01-01-2007 to 12-31-2007 data without passing the newer 2008 and 2009 data into the 2007 folder. ( Scratching my head on how to delete only this range of date/time stamped data after it is xcopied??? )

Below is an example of what I have so far, with explainations as to what I believe needs to happen in <   > between each xcopy /s/d:MM-DD-YYYY/y routine.

Run from C:

xcopy c:\data\*.*  c:\test1\2009\*.* /s/d:01-01-2009/y
<delete 2009 data so that next routine doesnt pass 2009 data to 2008. ???>
xcopy c:\data\*.*  c:\test1\2008\*.* /s/d:01-01-2008/y
<delete 2008 data so that next routine doesnt pass 2008 data to 2007. ???>
xcopy c:\data\*.*  c:\test1\2007\*.* /s/d:01-01-2007/y
<delete 2007 data so that next routine doesnt pass 2007 data to 2006. ???>
xcopy c:\data\*.*  c:\test1\2006\*.* /s/d:01-01-2006/y
<delete 2006 data so that next routine doesnt pass 2006 data to 2005. ???>
xcopy c:\data\*.*  c:\test1\2005\*.* /s/d:01-01-2005/y
<delete 2005 data so that next routine doesnt pass 2005 data to 2004. ???>
xcopy c:\data\*.*  c:\test1\2004\*.* /s/d:01-01-2004/y
<delete 2004 data so that next routine doesnt pass 2004 data to 2003. ???>
xcopy c:\data\*.*  c:\test1\2003\*.* /s/d:01-01-2003/y
<delete 2003 data so that next routine doesnt pass 2003 data to 2002. ???>
xcopy c:\data\*.*  c:\test1\2002\*.* /s/d:01-01-2002/y
<delete 2002 data so that next routine doesnt pass 2002 data to 2001. ???>
xcopy c:\data\*.*  c:\test1\2001\*.* /s/d:01-01-2001/y
<delete 2001 data so that next routine doesnt pass 2001 data to 2000. ???>
xcopy c:\data\*.*  c:\test1\2000\*.* /s/d:01-01-2000/y
rd data

This rd data is the final clean up to remove c:\data   after all data was moved into the grouped years with subdirectory data tree intact

Problem I have is how do you delete only data with date/time stamp of on say 01-01-2009 or after for each year to avoid the "/D:MM-DD-YYYY" passing newer data into what should be only the older specified directory path. I also want to keep the "/S" switch to maintain the directory path structure for data moved into the correct year of date/time stamp.

Any suggestions or code solutions vs the path I am taking with this project to group data by year?

I am guessing that there may be a better way and I am really butchering the purpose of the xcopy command by creating an individual instruction set for each year.

((OR)) can this be achieved without destroying the original C:\data source location to have the mixed data at c:\data and the sorted by year c:\test1\(year) locations by being able to set a date/time stamp range of 01-01-year to 12-31-year ??? ((if free space permitted!))

Thanks for your help in advance to the solution that you provide to my coding madness ...  ;D
I know one POSSIBLE way...but I'm not experienced enough to actually do it. If after each line, you delete the files created after 01-01-YEAR (you already copied them to a different directory). It could be acomplished with FOR...I think :-\
Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.

Dias de verano

  • Guest
Re: /D:MM-DD-YYYY troubles .... for sorting data by year into folders
« Reply #2 on: April 10, 2009, 04:56:52 PM »
Dave, maybe you should consider XXCOPY, which is like XCOPY on steroids, which has a free-for-personal-use version. It is designed to have similar command set to XCOPY.

There is also ROBOCOPY, a Microsoft admin tool, which, again, is designed to be be an easy transition from XCOPY, but I think for your problem as mentioned in this thread, consider this:

XXCOPY features include:

Quote
8. Select the range of file date

    XXCOPY c:\   d:\backup\  /S  /DA:1999-1-1  /DB:1999-6-30

    The file range of Date betwen Jan 1 and Jun 30 of 1999.
    /DA (On-or-After) and /DB (On-or-Before) bracket the date range.


http://www.xxcopy.com/index.htm


Helpmeh



    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
Re: /D:MM-DD-YYYY troubles .... for sorting data by year into folders
« Reply #3 on: April 10, 2009, 04:58:40 PM »
Maybe you should consider XXCOPY, which is like XCOPY on steroids, which has a free-for-personal-use version. It is designed to have similar command set to XCOPY.

There is also ROBOCOPY, a Microsoft admin tool, which, again, is designed to be be an easy transition from XCOPY, but I think for your problem as mentioned in this thread, consider this:

XXCOPY features include:

http://www.xxcopy.com/index.htm


It says it's compatible with XPSP3, as you may or may not know, I can't get that...can I still use XXCopy?
Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.

Dias de verano

  • Guest
Re: /D:MM-DD-YYYY troubles .... for sorting data by year into folders
« Reply #4 on: April 10, 2009, 05:04:36 PM »
It says it's compatible with XPSP3, as you may or may not know, I can't get that...can I still use XXCopy?

Compatible means it works OK with SP3. It doesn't mean you must have it.

Helpmeh



    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
Re: /D:MM-DD-YYYY troubles .... for sorting data by year into folders
« Reply #5 on: April 10, 2009, 05:07:29 PM »
Compatible means it works OK with SP3. It doesn't mean you must have it.

K
Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.

Reno



    Hopeful
  • Thanked: 32
    Re: /D:MM-DD-YYYY troubles .... for sorting data by year into folders
    « Reply #6 on: April 10, 2009, 11:49:16 PM »
    try this code, it's not optimized, if you have lot's of small size files, it might run slow. i am not good at xcopy, so i use copy command instead.
    Code: [Select]
    @echo off & setlocal enabledelayedexpansion
    pushd c:\data\ || goto:eof

    ::get system date format
    set f=
    for /f "skip=1 tokens=2-4* delims=(./-)" %%1 in ('echo.^|date') do (
            set 1=%%1
            set 2=%%2
            set 3=%%3
            for %%$ in (1 2 3) do if yy==!%%$! set f=!f!%%%%$
    )
    echo date format=%f%

    ::copy based on year modified
    for /r %%a in (*) do (
    for /f "tokens=1-3* delims=./- " %%1 in ("%%~ta") do set yy=%f%
    set dest=%%~dpa
    set dest=c:\test1\!yy!\!dest:%cd%\=!
    if not exist !dest! md "!dest!" && echo folder !dest! created
    echo copying %%a --^> !dest!
    copy "%%a" "!dest!"
    )
    popd


    WARNING: TRY ON TEST DATA FIRST. i am not responsible for any data lost.

    DaveLembke

      Topic Starter


      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: /D:MM-DD-YYYY troubles .... for sorting data by year into folders
    « Reply #7 on: April 11, 2009, 12:37:59 AM »
    Thanks Dias and Reno ... I will give both of your solutions a try in the morning and see which one works better. The XXCOPY seems pretty straight forward with the ability to set range like I need. But I also am interested in checking out Reno's coded solution as well to see how well that works too.

    Thanks for the effort of all who contributed...based on this info I think I should be all set now.   ;)

    DaveLembke

      Topic Starter


      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: /D:MM-DD-YYYY troubles .... for sorting data by year into folders
    « Reply #8 on: April 11, 2009, 11:43:45 AM »
    Reno .... VERY Impressed with your solution...Works perfect and no need to delete data from the C:\data location.

    Now off to sort 374GB of data after a successful test of about 50mb

    Thanks sooo much  !!!!   8)

    Helpmeh



      Guru

    • Roar.
    • Thanked: 123
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Familiar
    • OS: Windows 8
    Re: /D:MM-DD-YYYY troubles .... for sorting data by year into folders
    « Reply #9 on: April 13, 2009, 04:52:40 PM »
    Reno .... VERY Impressed with your solution...Works perfect and no need to delete data from the C:\data location.

    Now off to sort 374GB of data after a successful test of about 50mb

    Thanks sooo much  !!!!   8)
    If you run into any problems later, feel free to ask.
    Where's MagicSpeed?
    Quote from: 'matt'
    He's playing a game called IRL. Great graphics, *censored* gameplay.