WinXP/7zip. Daily and mnthly file archives

February 25, 2011 at 03:32:00
Specs: Windows XP
Good afternoon

I hope you can help

We have 3 systems providing an output file (currently a pdf but that's not important) every hour. I want to create an archive process so that when I run it, it consoloadates all the hourly interval data into correctly named daily data.

I want to do itbased on the actual filename rather than file creatation attributes as we often re-run the reports mannually

I used some VB scripting to give myself some sample files, 3 systems, 24 reports each per day, 365 days per year, results in something like 28K files.

Filenames look like:

"East_CBC-010120110030.pdf"
"East_CBC-010120110130.pdf"
"East_CBC-010120110230.pdf"
"East_CBC-010120110330.pdf"
"East_CBC-010120110430.pdf"
...
...
"West_CBC-051620111130.pdf"
"West_CBC-051620111230.pdf"
"West_CBC-051620111330.pdf"
"West_CBC-051620111430.pdf"
"West_CBC-051620111530.pdf"
"West_CBC-051620111630.pdf"
"West_CBC-051620111730.pdf"

"North_CBC-070420110330.pdf"
"North_CBC-070420110430.pdf"
"North_CBC-070420110530.pdf"
"North_CBC-070420110630.pdf"
"North_CBC-070420110730.pdf"
"North_CBC-070420110830.pdf"
"North_CBC-070420110930.pdf"


the date portion is *mmddyyyhhmm.pdf

I have no idea where to start with creatign a batch file and then zipping into an arcive.

can anyone point me in the direction?

The zip files I would like to create wouldbe called mmddyyyy.pdf and would contain the 24*3 hourly reports for that day...


...
...
..



See More: WinXP/7zip. Daily and mnthly file archives

Report •

#1
February 25, 2011 at 05:23:52
I don't use 7zip but with pkzip it might look like this:

:: ==========================================
::
:: rwylie.bat Fri 25-02-2011 19:10:34.70
@echo off & setLocal enableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b *.pdf') do (
set Z=%%~Na
set Z=!Z:~0,-4!
set Z=!Z:~-8!
echo pkzip !Z! %%a
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
February 25, 2011 at 09:10:12
Hi

Thank you for the quick reply.

So so close.

I just dones't seem to be doing the actual arcive:

Output on the cmd line:

7za a 12312011 West_CBC-123120111330.pdf
7za a 12312011 West_CBC-123120111430.pdf
7za a 12312011 West_CBC-123120111530.pdf
7za a 12312011 West_CBC-123120111630.pdf
7za a 12312011 West_CBC-123120111730.pdf
7za a 12312011 West_CBC-123120111830.pdf
7za a 12312011 West_CBC-123120111930.pdf
7za a 12312011 West_CBC-123120112030.pdf
7za a 12312011 West_CBC-123120112130.pdf
7za a 12312011 West_CBC-123120112230.pdf
7za a 12312011 West_CBC-123120112330.pdf

if I take any of these lines, it does successfully do the archive. it's almost like it's just not accepting it as a command, rather than just echo to the terminal .


Report •

#3
February 25, 2011 at 09:17:49
OK, so I'm an idiot! I removed the echo line before 7za!

Report •

Related Solutions

#4
March 1, 2011 at 01:41:16
Thank you very much. It works a treat.

My next step would be now to create a batch file that takes the daily zip files and collate them into a monthly zip.

01012011.zip
01022011.zip
01032011.zip

into 012011.zip

I would love to be able to understand the previously submitted code, but I have no idea to start with the following:

for /f "tokens=* delims= " %%a in ('dir/b *.pdf') do (
set Z=%%~Na
set Z=!Z:~0,-4!
set Z=!Z:~-8!
echo pkzip !Z! %%a
)


Report •

#5
March 1, 2011 at 02:45:41
With a bit of google help, and understanding how to strip of characters; I came up with:

:: ==========================================
::
:: monthly.bat Fri 25-02-2011 19:10:34.70
@echo off & setLocal enableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b *.7z') do (
set Z=%%~Na
REM echo Z - !Z!

set Y=!Z:~-4!
REM echo Y - !Y!

set M=!Z:~0,-6!
REM echo M- !M!

echo 7za a !M!!Y! %%a
)

seems to work for me.

Thank you again for your help


Report •

#6
March 1, 2011 at 03:13:53
Nice job.


=====================================
Life is too important to be taken seriously.

M2


Report •

#7
March 1, 2011 at 07:26:28
Thank you!

Do you happen to have any links to any tutorials/wiki that explain any of the following:

set Z=%%~Na
set Y=!Z:~-4!
set M=!Z:~0,-6!

I get the principle, but the use of tilda and % makes it a google nightmare!!



Report •

#8
March 1, 2011 at 23:38:12
Here's my cheat sheet.

~3 skip 3
~-3 last 3
~0,3 first 3
~0,-3 drop last 3


=====================================
Life is too important to be taken seriously.

M2


Report •

#9
March 1, 2011 at 23:50:12
As for additional reading:
SET /?

How To Ask Questions The Smart Way


Report •

#10
March 2, 2011 at 02:12:19
Super.

Thanks all!!


Report •

Ask Question