Report directory structure is pre created into a ..\year\month\day sub folder structure. So the date created time stamps of the folder object is not accurate for the sub folder and can't be used.
Examples:
I:\vpsreports\california\2016\01\14
I:\vpsreports\oregon\2016\01\14
I:\vpsreports\utah\2016\01\14
What I need to do is to zip the previous months directory which contains the daily sub folder and individual reports within.
Example:
In the 2015 sub folder it contain 12 manually created zip files for each months reports. So I:\vpsreports\oregon\2015\ has 01.zip, 02.zip, 03.zip, etc within it.
I have created other batch files that zip specific file types or by age but I can't seem to find a way to have a script run on the first of each month and zip the previous months directory. I hope this explains the situation I have clearly.
Thank you ahead of time for any help you provide.
Need to zip files in previous months folder
Moderator: DosItHelp
Re: Need to zip files in previous months folder
SteveZ wrote:I have created other batch files that zip specific file types or by age but I can't seem to find a way to have a script run on the first of each month and zip the previous months directory. I hope this explains the situation I have clearly.
Please clarify the question a bit further:
You showed 14th Jan 2016 but how many folders do you want to zip up?
Where is the ZIP file to be placed for 2016?
What program is being used to ZIP the files?
Re: Need to zip files in previous months folder
Thank you for your reply.
>>>You showed 14th Jan 2016 but how many folders do you want to zip up?
On the first of each month I would zip the previous months folder.
So if today was February 1st, I would winzip "I:\vpsreports\oregon\2016\01\*" into I:\vpsreports\oregon\2016\01.zip.
>>>Where is the ZIP file to be placed for 2016?
The previous months folder would remain under that year. If we were currently half way through 2016 the directory would then look like this example.
I:\vpsreports\oregon\2016\01.zip
I:\vpsreports\oregon\2016\02.zip
I:\vpsreports\oregon\2016\03.zip
I:\vpsreports\oregon\2016\04.zip
I:\vpsreports\oregon\2016\05.zip
I:\vpsreports\oregon\2016\06\*(01-30 daily sub folders)
I:\vpsreports\oregon\2016\07\*(01-31 daily sub folders)
I:\vpsreports\oregon\2016\08\*(01-31 daily sub folders)
I:\vpsreports\oregon\2016\09\*(01-30 daily sub folders)
I:\vpsreports\oregon\2016\10\*(01-31 daily sub folders)
I:\vpsreports\oregon\2016\11\*(01-30 daily sub folders)
I:\vpsreports\oregon\2016\12\*(01-31 daily sub folders)
One addition item to mention is the previous months files were deleted after being contained within the zip file.
So after I:\vpsreports\oregon\2016\06.zip is created, the original folders and files of I:\vpsreports\oregon\2016\06\*(01-30 daily sub folders) are deleted to reduce disk space.
>>>What program is being used to ZIP the files?
I have been using winzip command line "WZZIP".
I was trying to write a batch that would go to each sites yearly directory and then the previous month to then perform the zip of the previous months folder. I just can't seem to find a way to say -1 for the month.
Example:
CD I:\vpsreports\oregon\%date:~10,4%
wzzip -ybc -mu -x*.zip I:\vpsreports\oregon\%date:~10,4%\%date:~4,2%
CD I:\vpsreports\utah\%date:~10,4%
wzzip -ybc -mu -x*.zip I:\vpsreports\oregon\%date:~10,4%\%date:~4,2%
CD I:\vpsreports\california\%date:~10,4%
wzzip -ybc -mu -x*.zip I:\vpsreports\oregon\%date:~10,4%\%date:~4,2%
>>>You showed 14th Jan 2016 but how many folders do you want to zip up?
On the first of each month I would zip the previous months folder.
So if today was February 1st, I would winzip "I:\vpsreports\oregon\2016\01\*" into I:\vpsreports\oregon\2016\01.zip.
>>>Where is the ZIP file to be placed for 2016?
The previous months folder would remain under that year. If we were currently half way through 2016 the directory would then look like this example.
I:\vpsreports\oregon\2016\01.zip
I:\vpsreports\oregon\2016\02.zip
I:\vpsreports\oregon\2016\03.zip
I:\vpsreports\oregon\2016\04.zip
I:\vpsreports\oregon\2016\05.zip
I:\vpsreports\oregon\2016\06\*(01-30 daily sub folders)
I:\vpsreports\oregon\2016\07\*(01-31 daily sub folders)
I:\vpsreports\oregon\2016\08\*(01-31 daily sub folders)
I:\vpsreports\oregon\2016\09\*(01-30 daily sub folders)
I:\vpsreports\oregon\2016\10\*(01-31 daily sub folders)
I:\vpsreports\oregon\2016\11\*(01-30 daily sub folders)
I:\vpsreports\oregon\2016\12\*(01-31 daily sub folders)
One addition item to mention is the previous months files were deleted after being contained within the zip file.
So after I:\vpsreports\oregon\2016\06.zip is created, the original folders and files of I:\vpsreports\oregon\2016\06\*(01-30 daily sub folders) are deleted to reduce disk space.
>>>What program is being used to ZIP the files?
I have been using winzip command line "WZZIP".
I was trying to write a batch that would go to each sites yearly directory and then the previous month to then perform the zip of the previous months folder. I just can't seem to find a way to say -1 for the month.
Example:
CD I:\vpsreports\oregon\%date:~10,4%
wzzip -ybc -mu -x*.zip I:\vpsreports\oregon\%date:~10,4%\%date:~4,2%
CD I:\vpsreports\utah\%date:~10,4%
wzzip -ybc -mu -x*.zip I:\vpsreports\oregon\%date:~10,4%\%date:~4,2%
CD I:\vpsreports\california\%date:~10,4%
wzzip -ybc -mu -x*.zip I:\vpsreports\oregon\%date:~10,4%\%date:~4,2%
Re: Need to zip files in previous months folder
SteveZ wrote:I was trying to write a batch that would go to each sites yearly directory and then the previous month to then perform the zip of the previous months folder. I just can't seem to find a way to say -1 for the month.
Example:
CD I:\vpsreports\oregon\%date:~10,4%
if you want a hint to subtract one from the current day then try this:
The last line sets it to December in the previous year but you will have to decide what you want to do when it's January.
Code: Select all
set y=%date:~10,4%
set d=1%date:~4,2%
set /a d-=1
set d=%d:~-2%
if "%d%"=="00" set d=12&set /a y-=1