Any objection to VBScript? Not sure what the two parameters are that you need 
to supply, since it seems that the values are fixed (today - 45 days). Or are 
you saying that you could have files generated with arbitrary dates today, and 
you only want to move the ones that have dates older than 45 days prior to 
today moved?


' Subtract 45 days from Today
dTheDate = DateAdd("d", -45, Date())

' Look for Filename
sFileName = Month(dTheDate) & Day(dTheDate) & Year(dTheDate()) & ".7z"

' Set Source and Destination Directories
sSrcDir = "c:\myFiles"
sDstDir = "c:\" & MonthName(Month(dTheDate), True) & Year(dTheDate)  ' 
MonthName optional parameter provides 3 letter abbreviation of Month

' Copy File
Set oFS = CreateObject("Scripting.FileSystemObject")
oFS.CopyFile sFileName, "c:\tempfolder\"
Set oFS = Nothing


From: [email protected] [mailto:[email protected]] On 
Behalf Of David McSpadden
Sent: Tuesday, 3 June 2014 9:14 PM
To: '[email protected]'
Subject: [NTSysADM] copy files to folders

I would like on a Server 2012 box to run a powershell or dos batch that will do 
the following:
Copy file x to folder y. Where file x is passed as parm %1 and folder y as parm 
%2.
These are all date files and month/year folders.
For example file 041014.7z is moved to folder Apr 2014 in the same parent 
folder and file
050114.7z is moved to folder May 2014.
This is a daily job that would be running 45 days in the past.
So today 06/03/2014 the job would be looking at 04/19/2014.
I think I want a standard batch/powershell that looks at the first 2 and 5-6 
char of filename and
Moves that file to the mmm yyyy folder that equates.
So in the batch file there will be a for, if or do/while case going on. Not 
sure about the powershell?

Any words of wisdom?  Either way is acceptable.  Just lack the brainpower to 
get it done this morning.




Reply via email to