Here is what I ended up with:
cls
@echo on
set copystr=%2
set str1=%1
echo.%str1%
@echo off
SET MONTH2=%str1:~0,2%
IF "%MONTH2%"=="01" SET MONTH3=Jan
IF "%MONTH2%"=="02" SET MONTH3=Feb
IF "%MONTH2%"=="03" SET MONTH3=Mar
IF "%MONTH2%"=="04" SET MONTH3=Apr
IF "%MONTH2%"=="05" SET MONTH3=May
IF "%MONTH2%"=="06" SET MONTH3=Jun
IF "%MONTH2%"=="07" SET MONTH3=Jul
IF "%MONTH2%"=="08" SET MONTH3=Aug
IF "%MONTH2%"=="09" SET MONTH3=Sep
IF "%MONTH2%"=="10" SET MONTH3=Oct
IF "%MONTH2%"=="11" SET MONTH3=Nov
IF "%MONTH2%"=="12" SET MONTH3=Dec

SET YEAR2=%str1:~4,2%
IF "%YEAR2%"=="01" SET YEAR4=2001
IF "%YEAR2%"=="02" SET YEAR4=2002
IF "%YEAR2%"=="03" SET YEAR4=2003
IF "%YEAR2%"=="04" SET YEAR4=2004
IF "%YEAR2%"=="05" SET YEAR4=2005
IF "%YEAR2%"=="06" SET YEAR4=2006
IF "%YEAR2%"=="07" SET YEAR4=2007
IF "%YEAR2%"=="08" SET YEAR4=2008
IF "%YEAR2%"=="09" SET YEAR4=2009
IF "%YEAR2%"=="10" SET YEAR4=2010
IF "%YEAR2%"=="11" SET YEAR4=2011
IF "%YEAR2%"=="12" SET YEAR4=2012
IF "%YEAR2%"=="13" SET YEAR4=2013
IF "%YEAR2%"=="14" SET YEAR4=2014
IF "%YEAR2%"=="15" SET YEAR4=2015
IF "%YEAR2%"=="16" SET YEAR4=2016
IF "%YEAR2%"=="17" SET YEAR4=2017
IF "%YEAR2%"=="18" SET YEAR4=2018
IF "%YEAR2%"=="19" SET YEAR4=2019
IF "%YEAR2%"=="20" SET YEAR4=2020
@echo on
set str2=%MONTH3% %YEAR4%


COPY %CopyStr%\%str1% "%CopyStr%\%str2%"\%str1% /Y
DEL %CopyStr%\%str1% /F /Q

Where %1 = 041914.7z
And %2 = e:\reports\

From: [email protected] [mailto:[email protected]] On 
Behalf Of Ken Schaefer
Sent: Tuesday, June 03, 2014 8:10 AM
To: [email protected]
Subject: [NTSysADM] RE: copy files to folders

' Fixed the .CopyFile call

' 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 sSrcDir & "\" & sFileName, sDstDir
Set oFS = Nothing



From: [email protected] [mailto:[email protected]] On 
Behalf Of Ken Schaefer
Sent: Tuesday, 3 June 2014 10:03 PM
To: [email protected]
Subject: [NTSysADM] RE: copy files to folders

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]> 
[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.



This e-mail and any files transmitted with it are property of Indiana Members 
Credit Union, are confidential, and are intended solely for the use of the 
individual or entity to whom this e-mail is addressed. If you are not one of 
the named recipient(s) or otherwise have reason to believe that you have 
received this message in error, please notify the sender and delete this 
message immediately from your computer. Any other use, retention, 
dissemination, forwarding, printing, or copying of this email is strictly 
prohibited.

Please consider the environment before printing this email.

Reply via email to