<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TechBlog &#187; Zip</title>
	<atom:link href="http://techblog.byllemos.com/tag/zip/feed/" rel="self" type="application/rss+xml" />
	<link>http://techblog.byllemos.com</link>
	<description>Accelerating into the Future with Wisdom about Technology! Ingrid Byllemos</description>
	<lastBuildDate>Tue, 05 Jan 2010 00:04:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Zip files in a script</title>
		<link>http://techblog.byllemos.com/2006/05/zip-files-in-a-script/</link>
		<comments>http://techblog.byllemos.com/2006/05/zip-files-in-a-script/#comments</comments>
		<pubDate>Wed, 03 May 2006 22:46:05 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[DOS]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[AT]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Zip]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=44</guid>
		<description><![CDATA[<p>If you have an application running, which creates a lot of log files &#8211; it would be neat to have simple functionality to zip those files. This is possible, just using dos scripts and the AT functionality.</p>
<p>First the script&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>If you have an application running, which creates a lot of log files &#8211; it would be neat to have simple functionality to zip those files. This is possible, just using dos scripts and the AT functionality.</p>
<p>First the script – it could look something like this:</p>
<p><span id="more-44"></span></p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">FindDate ----------------------------------------------------
for /f &quot;tokens=<span style="">1</span>-<span style="">4</span> delims=/.- &quot; %%A in <span class="br0">&#40;</span>'date /t'<span class="br0">&#41;</span> do <span class="br0">&#40;</span>
    set DD=%%A&amp;set MM=%%B&amp;set YYYY=%%C&amp;set Junk=%%D&amp;goto End<span class="br0">&#41;</span>
&nbsp;
:Parse --------------------------------------------------------------
echo Date: YYYY=%YYYY% MM=%MM% DD=%DD% JUNK=%Junk%
&nbsp;
:End ----------------------------------------------------------------
move c:\log\*.log c:\log\*.bck
c:\tools\zip.exe -m c:\log\Log%YYYY%-%MM%-%DD%.zip c:\log\*.bck</div></pre><!--END_DEVFMTCODE--><br />
</p>
<p>Lets take a closer look.</p>
<p>First we get today&#8217;s date by getting date and splitting into the peaces YYYY, MM, DD, JUNK, where JUNK is seconds, milliseconds and so on.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">
for /f &quot;tokens=1-4 delims=/.- &quot; %%A in <span class="br0">&#40;</span>'date /t'<span class="br0">&#41;</span> do <span class="br0">&#40;</span>
set DD=%%A&amp;amp;set MM=%%B&amp;amp;set YYYY=%%C&amp;amp;set Junk=%%D&amp;amp;goto End<span class="br0">&#41;</span></div></pre><!--END_DEVFMTCODE--></p>
<p>Notice – the setting of DD, MM and so on, differs from system to system. The above line works for a Windows 2003, where as the following line would work for a Windows 2000:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">set Junk=%%A&amp;amp;set DD=%%B&amp;amp;set MM=%%C&amp;amp;set YYYY=%%D&amp;amp;goto End<span class="br0">&#41;</span></div></pre><!--END_DEVFMTCODE--></p>
<p>Next we moves the files, this is to make sure that no application is writing to it.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">move c:\log\*.log c:\log\*.bck</div></pre><!--END_DEVFMTCODE--></p>
<p>and finaly the files are being zipped, using a dos version of zip.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">c:\tools\zip.exe -m c:\log\backup\Log%YYYY%-%MM%-%DD%.zip c:\log\*.bck</div></pre><!--END_DEVFMTCODE--></p>
<p>Now you have build the script, and can save into a file called backup.cmd (the extension could also be bat).</p>
<p>The next thing to do, is getting the script scheduled. In this way we don&#8217;t have to execute it manually every day. To do this we are using the AT command.</p>
<p>In a DOS prompt write:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">AT 04:00 /every:M,T,W,TH,F,S,SU c:\tools\backup.cmd</div></pre><!--END_DEVFMTCODE--></p>
<p>Which means, that the script backup.cmd will be execute every day at 04:00. If you want to stop the scheduled job, simply perform an AT without parameters to get the ID and then afterwards make a AT ID /DELETE.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2006/05/zip-files-in-a-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

