![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Copy files based upon Create Date I need to have a process that looks at a Network shared folder \\Archive\datafiles and based upon file date creation create another folder within this structure to move them to. example.. files in folder \\Archive\datafiles abc.xls 1/5/08 def.xls 1/15/08 ghi.chs 1/20/08 com1.xls 2/2/08 com4.xls 2/5/08 After script runs new folders created \\Archive\datafiles\Jan08 \\Archive\datafiles\Feb08 Then inside \\Archive\datafiles\Jan08 abc.xls 1/5/08 def.xls 1/15/08 ghi.chs 1/20/08 \\Archive\datafiles\Feb08 com1.xls 2/2/08 com4.xls 2/5/08 They are no longer on the root \\Netstore\datafiles but inside there Monthly folder. This process will run the 1st day of the new month to grab what will be last months files. I need this script to catch up the process. Thanks. |
My System Specs![]() |
| | #2 (permalink) |
| Vista Home Premium 32bit | Re: Copy files based upon Create Date You can create the different folders in this way gci | % {$_.creationtime.tostring("MMMyy")} | sort | get-unique | % {md $_} then you can create two array, one for the files and one for the folders $folders = gci | ? {$_.psiscontainer} $files = gci | ? {-not $_.psiscontainer} and finally you can loop each file and compare it with the folder name foreach ($file in $files) {foreach($folder in $folders) {if($file.creationtime.tostring("MMMyy") -eq $folder) {copy-item $file -destination $folder}}} if everything works well you can use move-item instead of copy-item. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Copy files based upon Create Date Can this also be logged so at the end of the process you get xxx files copied to xxxfolder "sardinian_guy" <guest@xxxxxx-email.com> wrote in message news:5c1e6e75582755ccf75dafec3675fa0f@xxxxxx-gateway.com... Quote: > > You can create the different folders in this way > > gci | % {$_.creationtime.tostring("MMMyy")} | sort | get-unique | % {md > $_} > > then you can create two array, one for the files and one for the > folders > > $folders = gci | ? {$_.psiscontainer} > $files = gci | ? {-not $_.psiscontainer} > > and finally you can loop each file and compare it with the folder name > > foreach ($file in $files) {foreach($folder in $folders) > {if($file.creationtime.tostring("MMMyy") -eq $folder) {copy-item $file > -destination $folder}}} > > if everything works well you can use move-item instead of copy-item. ![]() > > > -- > sardinian_guy |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| powershell script help - recursive delete based on modified date | PowerShell | |||
| Deleteing Files in a folder based on date! | Vista file management | |||
| I want to create a PC based email account | Vista mail | |||
| Delete files based on last accessed date? | PowerShell | |||
| Delete based on date | PowerShell | |||