Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Move files based on date into new folder whilst keeping the struct

Reply
Thread Tools Display Modes

Move files based on date into new folder whilst keeping the struct

 
 
Dave Pearce
Guest
Posts: n/a

 
      12-17-2009
Hello wonder if you can help.

I have a folder with lot's of files written in it from 2005-present day.
What i need to script is move files from this location and sort them by years
whilst keeping the existing structure. I have looked at the syntax of xcopy
and robocopy but not sure whats the best way to move forward for exmaple

d:\docs\word\file1.doc (created in 2006) would move to d:\2006\word\file1.doc

d:\docs\excel\john\file2.xls (created in 2005) would move to
d:\2005\excel\john\file2.xls

And so on. I can make the script once i have an idea on the best way to take
it forward.

Many Thanks in advance.

Regards
Dave

--
ICT Development
 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a

 
      12-17-2009


"Dave Pearce" <> screv in
news:4C4C614D-0779-42BF-84C6-...
> Hello wonder if you can help.
>
> I have a folder with lot's of files written in it from 2005-present day.
> What i need to script is move files from this location and sort them by
> years
> whilst keeping the existing structure. I have looked at the syntax of
> xcopy
> and robocopy but not sure whats the best way to move forward for exmaple
>
> d:\docs\word\file1.doc (created in 2006) would move to
> d:\2006\word\file1.doc
>
> d:\docs\excel\john\file2.xls (created in 2005) would move to
> d:\2005\excel\john\file2.xls
>
> And so on. I can make the script once i have an idea on the best way to
> take
> it forward.
>
> Many Thanks in advance.
>
> Regards
> Dave
>
> --
> ICT Development


Seeing that you mention robocopy and xcopy, you probably want a batch file
rather than a VB Script file. Here is one that will do the trick:
@echo off
set Source=d:\Docs
set Target=d:
set Year=2005
set /a NYear=%Year% + 1
set Switches= /s /mov /MinAge:%NYear%0101
robocopy "%Source%" "%Target%\%Year%" *.* %Switches%

Adjust the first three "set" commands to suit your environment. Note that
neither the Source nor the Target must have a trailing backslash. Run the
file for the oldest year first, then move up by one year at a time. I urge
you to do a trial run with a disposable source directory until you're
satisfied with the result.

 
Reply With Quote
 
Dave Pearce
Guest
Posts: n/a

 
      12-19-2009
This worked perfectly. Did the /COPY first to test.

Many Thanks for your help.

Kind Regards
Dave
--
ICT Development


"Pegasus [MVP]" wrote:

>
>
> "Dave Pearce" <> screv in
> news:4C4C614D-0779-42BF-84C6-...
> > Hello wonder if you can help.
> >
> > I have a folder with lot's of files written in it from 2005-present day.
> > What i need to script is move files from this location and sort them by
> > years
> > whilst keeping the existing structure. I have looked at the syntax of
> > xcopy
> > and robocopy but not sure whats the best way to move forward for exmaple
> >
> > d:\docs\word\file1.doc (created in 2006) would move to
> > d:\2006\word\file1.doc
> >
> > d:\docs\excel\john\file2.xls (created in 2005) would move to
> > d:\2005\excel\john\file2.xls
> >
> > And so on. I can make the script once i have an idea on the best way to
> > take
> > it forward.
> >
> > Many Thanks in advance.
> >
> > Regards
> > Dave
> >
> > --
> > ICT Development

>
> Seeing that you mention robocopy and xcopy, you probably want a batch file
> rather than a VB Script file. Here is one that will do the trick:
> @echo off
> set Source=d:\Docs
> set Target=d:
> set Year=2005
> set /a NYear=%Year% + 1
> set Switches= /s /mov /MinAge:%NYear%0101
> robocopy "%Source%" "%Target%\%Year%" *.* %Switches%
>
> Adjust the first three "set" commands to suit your environment. Note that
> neither the Source nor the Target must have a trailing backslash. Run the
> file for the oldest year first, then move up by one year at a time. I urge
> you to do a trial run with a disposable source directory until you're
> satisfied with the result.
>
> .
>

 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a

 
      12-19-2009


"Dave Pearce" <> screv in
news05F0892-511B-4DF7-8B58-...
> This worked perfectly. Did the /COPY first to test.
>
> Many Thanks for your help.
>
> Kind Regards
> Dave
> --
> ICT Development
>


Thanks for the feedback.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Move Outlook .pst files from old XP computer to new Vista computer Crausch Windows Vista File Management 15 07-14-2009 11:47 PM
Files Remain Hidden Even though I selected show Hidden & Protected LabTechnician Windows Vista File Management 11 03-02-2008 09:08 AM
Can't save file in localized folder Carl Windows Vista File Management 2 08-06-2007 09:58 PM
File not in Explorer but opens anyhow Toyman Windows Vista File Management 5 07-24-2007 11:06 PM
HELP sfc /scannow William Beard Windows Vista Performance 17 05-11-2007 03:28 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59