GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/nginx/html/JimMartinson/_Archive/CST1861/dostips.com/ |
Upload File : |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html lang="en-US"><head><link media="all" href="DOS%20Batch%20-%20Advanced%20Template_files/widget64.css" type="text/css" rel="stylesheet"> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <meta content="TRUE" name="MSSmartTagsPreventParsing"> <meta http-equiv="expires" content="-1"> <meta http-equiv="pragma" content="no-cache"> <meta content="all" name="robots"> <meta name="keywords" content="dos,functions,vista,xp,command line,batch,examples,substring,variables,copies,date"> <link rel="Stylesheet" type="text/css" media="all" href="DOS%20Batch%20-%20Advanced%20Template_files/_style.css"> <link rel="shortcut icon" href="http://www.dostips.com/favicon.ico"> <link rel="icon" href="http://www.dostips.com/animated_favicon1.gif" type="image/gif"> <title>DOS Batch - File Examples</title> </head> <body><div id="_atssh" style="visibility: hidden; height: 1px; width: 1px; position: absolute; z-index: 100000;"><iframe src="DOS%20Batch%20-%20Advanced%20Template_files/sh49.htm" style="height: 1px; width: 1px; position: absolute; z-index: 100000; border: 0pt none; left: 0pt; top: 0pt;" title="AddThis utility frame" id="_atssh273"></iframe></div> <div class="nav"> <!-- AddThis Button BEGIN --> <div class="addthis_toolbox addthis_default_style"> <a href="#" title="Send to Facebook" class="addthis_button_facebook at300b"><span class="at300bs at15nc at15t_facebook"></span></a> <a href="#" title="Email" class="addthis_button_email at300b"><span class="at300bs at15nc at15t_email"></span></a> <a href="#" title="Save to Favorites" class="addthis_button_favorites at300b"><span class="at300bs at15nc at15t_favorites"></span></a> <a href="#" title="Print" class="addthis_button_print at300b"><span class="at300bs at15nc at15t_print"></span></a> <span class="addthis_separator">|</span> <a title="View more services" href="http://www.addthis.com/bookmark.php?v=250&username=cmdtips" class="addthis_button_expanded at300m"><span class="at300bs at15nc at15t_expanded"></span>More</a> <div class="atclear"></div></div> <script type="text/javascript" src="DOS%20Batch%20-%20Advanced%20Template_files/addthis_widget.js"></script> <!-- AddThis Button END --> <br> <div class="navi"> <a href="http://www.dostips.com/"><img src="DOS%20Batch%20-%20Advanced%20Template_files/TitleDostips.JPG" alt="DosTips.com" height="80"></a> <br><span style="font-size: 9px; font-weight: bold;">for Windows7,VISTA,XP,NT,Server 2000,</span> <br><span style="font-size: 9px; font-weight: bold;">Server 2003,Server 2008</span> <br> <br> <!-- SiteSearch Google --> <form style="margin: 5" method="get" action="http://www.dostips.com/DtGeneSearch.php" target="_top"> <span style="font-size: 11px;">Search:</span> <input name="domains" value="cmdtips.com" type="hidden"> <input name="q" size="12" maxlength="255" value="Google" onclick="this.value=''" type="text"> <input name="sitesearch" value="www.dostips.com" type="hidden"> <input name="sa" src="DOS%20Batch%20-%20Advanced%20Template_files/search.gif" value="Search" alt="Search" style="width: 20px; height: 20px; vertical-align: middle; border: medium none;" type="image"> <input name="client" value="pub-4331089886589220" type="hidden"> <input name="forid" value="1" type="hidden"> <input name="ie" value="ISO-8859-1" type="hidden"> <input name="channel" value="0649133363" type="hidden"> <input name="oe" value="ISO-8859-1" type="hidden"> <input name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:11" type="hidden"> <input name="hl" value="en" type="hidden"> </form> <!-- SiteSearch Google --> <br> <ul> <li class="nsel"><a href="http://www.dostips.com/">Home</a> <ul> <li class="nsel"> </li> </ul> </li> <li class="nsel"><a>Source Script</a> <ul> <li class="ysel"><a href="http://www.dostips.com/DtCodeBatchFiles.php">Batch Files</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtCodeFunctions.php">Functions</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtCodeCmdLib.php">Function Library</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtCodeSnippets.php">Script Snippets</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtCodeInterfacing.php">Interfacing</a> </li> <li class="nsel"> </li> </ul> </li> <li class="nsel"><a>Tips and Tricks</a> <ul> <li class="nsel"><a href="http://www.dostips.com/DtTipsXCopy.php">Copy Tips</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtTipsMenu.php">Menu in Batch</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtTipsStringManipulation.php">String Manipulation</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtTipsStringOperations.php">String Operations</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtTipsDateTime.php">Date and Time</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtTipsArithmetic.php">Arithmetic</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtTipsFtpBatchScript.php">FTP Batch Script</a> </li> <li class="nsel"><a href="http://www.dostips.com/DosCommandIndex.php">Command Index</a> </li> <li class="nsel"> </li> </ul> </li> <li class="nsel"><a>Tutorials</a> <ul> <li class="nsel"><a href="http://www.dostips.com/DtTutoFirstBatch.php">My First Batch</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtTutoFramework.php">Solid Framwork</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtTutoFunctions.php">Functions</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtTutoPersistency.php">Persistency</a> </li> <li class="nsel"> </li> </ul> </li> <li class="nsel"><a href="http://www.dostips.com/forum/viewforum.php?f=3">Forum</a> <ul> <li class="nsel"> </li> </ul> </li> <li class="nsel"><a href="http://www.dostips.com/DtGeneGeneral.php">General</a> <ul> <li class="nsel"><a href="http://www.dostips.com/DtGeneTermsOfUse.php">Terms of Use</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtGeneEnabler.php">Enablers</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtGeneAboutUs.php">About Us</a> </li> <li class="nsel"><a href="http://www.dostips.com/DtGeneContact.php">Contact Us</a> </li> <li class="nsel"> </li> </ul> </li> <li class="nsel"><a>Other</a> <ul> <li class="nsel"><a href="http://www.dot5hosting.com/join/index.bml?AffID=570595&LinkName=dot5txt">Get Web Hosting</a> </li> <li class="nsel"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9018663"><marquee scrollamount="2" width="120">Want donate a cup of Cafe? . click . </marquee></a> </li> <li class="nsel"> </li> </ul> </li> </ul> </div> </div> <h1>DOS Batch - File Examples</h1> <span class="shortText">A collection of batch files.</span><br><br> <table class="posts"> </table> <br><table class="menu" cellpadding="0" cellspacing="0"> <tbody><tr><td colspan="2"> </td></tr> <tr><td class="title"><a href="#Batch.FtpPure">Classic FTP</a></td> <td class="text">Executing a FTP script.</td> </tr> <tr><td class="title"><a href="#Batch.Menu2">DOS Batch - Advanced Menu</a></td> <td class="text">Toggle menu options, persist settings for the next run.</td> </tr> <tr><td class="title"><a href="#Batch.AdvancedTemplate">DOS Batch - Advanced Template</a></td> <td class="text">Template with version history, window title, delayed automatic exit.</td> </tr> <tr><td class="title"><a href="http://www.dostips.com/DtCodeBatchFiles.php">DOS Batch - File Examples</a></td> <td class="text">A collection of batch files.</td> </tr> <tr><td class="title"><a href="#Batch.FileList">DOS Batch - File Search List</a></td> <td class="text">Quickly find a file on your hard drive.</td> </tr> <tr><td class="title"><a href="#Batch.FindAndReplace">DOS Batch - Find and Replace</a></td> <td class="text">Search a file and replace all occurrences of a string with another string.</td> </tr> <tr><td class="title"><a href="#Batch.DeletePrintJobs">DOS Batch - Force Delete All Print Jobs</a></td> <td class="text">Get rid of these pesky print jobs.</td> </tr> <tr><td class="title"><a href="http://www.dostips.com/DtTipsFtpBatchScript.php">DOS Batch - FTP Scripts</a></td> <td class="text">File Transfer with FTP, One-File Solutions.</td> </tr> <tr><td class="title"><a href="http://www.dostips.com/DtCodeInterfacing.php">DOS Batch - Interfacing non DOS Software</a></td> <td class="text">Embed other languages into your batch, like: Perl, SQL, FTP, ...</td> </tr> <tr><td class="title"><a href="#Batch.Progress">DOS Batch - Progress</a></td> <td class="text">Show progress in batch using the title bar</td> </tr> <tr><td class="title"><a href="#Quine.Quine_1_3">DOS Batch - Quine 109 bytes</a></td> <td class="text">A pretty short DOS Batch Quine.</td> </tr> <tr><td class="title"><a href="#Quine.Quine_2_2">DOS Batch - Quine 134 bytes</a></td> <td class="text">A pretty short DOS Batch Quine.</td> </tr> <tr><td class="title"><a href="#Quine.Quine_1_1_1">DOS Batch - Quine 159 bytes</a></td> <td class="text">A pretty short DOS Batch Quine.</td> </tr> <tr><td class="title"><a href="#Quine.Quine_1_2">DOS Batch - Quine 259 bytes</a></td> <td class="text">A DOS Batch Quine that makes no assumption.</td> </tr> <tr><td class="title"><a href="#Quine.Quine_1_1">DOS Batch - Quine 301 bytes</a></td> <td class="text">A DOS Batch Quine that makes no assumption.</td> </tr> <tr><td class="title"><a href="#Quine.Quine_2_1">DOS Batch - Quine 308 bytes</a></td> <td class="text">A DOS Batch Quine that makes no assumption.</td> </tr> <tr><td class="title"><a href="#Quine.Shortest">DOS Batch - Shortest Quine 109 Bytes</a></td> <td class="text">Likely the shortest DOS Batch Quine ever.</td> </tr> <tr><td class="title"><a href="#Batch.Menu">DOS Batch - Simple Menu</a></td> <td class="text">Simple menu framework. Plug in a new menu item and coresponding script as single function block.</td> </tr> <tr><td class="title"><a href="#Batch.SortTextWithNumbers">DOS Batch - Sorting text with numbers</a></td> <td class="text">Sorting that handles numbers as numbers not text.</td> </tr> <tr><td class="title"><a href="#Batch.FunctionTemplate">DOS Function Template</a></td> <td class="text">A function template with all features of a true DOS function.</td> </tr> <tr><td class="title"><a href="#Batch.CommandIndex">DOS Help File Builder</a></td> <td class="text">Command reference in HTML format via batch.</td> </tr> <tr><td class="title"><a href="#Batch.FileDate">File age in days</a></td> <td class="text">Convert the file date into Julian Days to determine the age of a file age in days.</td> </tr> <tr><td class="title"><a href="#Batch.FtpBatchAutoLogin">FTP - Automatic Login</a></td> <td class="text">Automatically login to your FTP session with a single click.</td> </tr> <tr><td class="title"><a href="#Batch.FtpBatchDownloadOnlyNewFiles">FTP - Download Only New Files</a></td> <td class="text">Ftp script to download only files that don`t exist in local folder, i.e. to avoid overwrite</td> </tr> <tr><td class="title"><a href="#Batch.FtpBatchUsingVariables">FTP - Resolving Environment Variables</a></td> <td class="text">Creating FTP script on the fly at runtime and using variables within the FTP script.</td> </tr> <tr><td class="title"><a href="#Batch.FtpBatch">FTP - Simple Single Batch</a></td> <td class="text">FTP script and batch in a single file.</td> </tr> <tr><td class="title"><a href="#Batch.FtpBatchUploadOnlyNewFiles">FTP - Upload Only New Files</a></td> <td class="text">Ftp script to upload only files that don`t exist in remote folder, i.e. incremental upload.</td> </tr> <tr><td class="title"><a href="#Batch.FtpBatchLoginSharing">FTP Scripts Sharing Login Info</a></td> <td class="text">Manage the FTP login separately from your FTP scripts.</td> </tr> <tr><td class="title"><a href="#Interfacing.Sql">OSQL.EXE - Run SQL script from DOS Batch</a></td> <td class="text">SQL script and dos batch script in one file, the One-File Solution</td> </tr> <tr><td class="title"><a href="#Interfacing.Sql2">OSQL.EXE - Run SQL script from DOS Batch, passing parameters</a></td> <td class="text">Run SQL scripts with parameters passed in from the batch script.</td> </tr> <tr><td class="title"><a href="#Interfacing.Perl">Perl - Perl Script within a DOS Batch</a></td> <td class="text">Perl script and batch in a single file.</td> </tr> <tr><td class="title"><a href="#Interfacing.Perl2">Perl Script within a DOS Batch with delayed exit</a></td> <td class="text">Perl script and batch in a single file.</td> </tr> <tr><td class="title"><a href="#Batch.SimpleTemplate">Simple Batch Template</a></td> <td class="text">Template with simple init and exit.</td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Batch.FtpPure"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>Classic FTP - Executing a FTP script</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>The FTP command support the "-s:ftpscript.txt" option. The FTP commands listed in ftpscript.txt will automatically run after FTP starts. The FTP command can be started from a batch file.</p> Example: <ul> <li>FTP -v -i -s:ftpscript.txt</li> </ul> See also command line help: "C:>ftp -?"</td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">open example.com</span><br> <span style="color=#000000">username</span><br> <span style="color=#000000">password</span><br> <span style="color=#000000">!:--- FTP commands below here ---</span><br> <span style="color=#000000">lcd c:\MyLocalDirectory</span><br> <span style="color=#000000">cd public_html/MyRemoteDirectory</span><br> <span style="color=#000000">binary</span><br> <span style="color=#000000">mput "*.*"</span><br> <span style="color=#000000">disconnect</span><br> <span style="color=#000000">bye</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>ftp> open example.com User (Username:(none)): ftp> !:--- FTP commands below here --- ftp> lcd c:\MyLocalDirectory Local directory now c:\MyLocalDirectory. ftp> cd public_html/MyRemoteDirectory ftp> binary ftp> !: mput "*.*" ftp> disconnect ftp> bye </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Batch.Menu2"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>DOS Batch - Advanced Menu - Toggle menu options, persist settings for the next run</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">Example - Installation Framework. <p>This example shows how to enhance a program with persistent settings that can be changed using a menu.</p> <p>I.e.: </p><ul> <li>Choose 1 to change the 'Install version' from 'Client' to 'Server'.</li> <li>Choose 1 again to change the 'Install version' back to 'Client'.</li> <li>Choose 2 to change the 'Size of installation' from Full to 'Regular'.</li> <li>Choose 2 again to change the 'Size of installation' to 'Mini'.</li> <li>Choose 2 again to change the 'Size of installation' back to 'Full'.</li> <li>Choose I to begin the installation. Note: this example is just a simulation and will not install anything on your PC.</li> </ul> <p></p> Features: <ul> <li>simple and well structured</li> <li>settings changeable at runtime</li> <li><b>settings are persistent</b>, the batch will remember all settings from the last run</li> <li><b>progress indication</b> during simulated file installation</li> </ul></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchInstall.bat">BatchInstall.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br><a name="12">12.</a><br><a name="13">13.</a><br><a name="14">14.</a><br><a name="15">15.</a><br><a name="16">16.</a><br><a name="17">17.</a><br><a name="18">18.</a><br><a name="19">19.</a><br><a name="20">20.</a><br><a name="21">21.</a><br><a name="22">22.</a><br><a name="23">23.</a><br><a name="24">24.</a><br><a name="25">25.</a><br><a name="26">26.</a><br><a name="27">27.</a><br><a name="28">28.</a><br><a name="29">29.</a><br><a name="30">30.</a><br><a name="31">31.</a><br><a name="32">32.</a><br><a name="33">33.</a><br><a name="34">34.</a><br><a name="35">35.</a><br><a name="36">36.</a><br><a name="37">37.</a><br><a name="38">38.</a><br><a name="39">39.</a><br><a name="40">40.</a><br><a name="41">41.</a><br><a name="42">42.</a><br><a name="43">43.</a><br><a name="44">44.</a><br><a name="45">45.</a><br><a name="46">46.</a><br><a name="47">47.</a><br><a name="48">48.</a><br><a name="49">49.</a><br><a name="50">50.</a><br><a name="51">51.</a><br><a name="52">52.</a><br><a name="53">53.</a><br><a name="54">54.</a><br><a name="55">55.</a><br><a name="56">56.</a><br><a name="57">57.</a><br><a name="58">58.</a><br><a name="59">59.</a><br><a name="60">60.</a><br><a name="61">61.</a><br><a name="62">62.</a><br><a name="63">63.</a><br><a name="64">64.</a><br><a name="65">65.</a><br><a name="66">66.</a><br><a name="67">67.</a><br><a name="68">68.</a><br><a name="69">69.</a><br><a name="70">70.</a><br><a name="71">71.</a><br><a name="72">72.</a><br><a name="73">73.</a><br><a name="74">74.</a><br><a name="75">75.</a><br><a name="76">76.</a><br><a name="77">77.</a><br><a name="78">78.</a><br><a name="79">79.</a><br><a name="80">80.</a><br><a name="81">81.</a><br><a name="82">82.</a><br><a name="83">83.</a><br><a name="84">84.</a><br><a name="85">85.</a><br><a name="86">86.</a><br><a name="87">87.</a><br><a name="88">88.</a><br><a name="89">89.</a><br><a name="90">90.</a><br><a name="91">91.</a><br><a name="92">92.</a><br><a name="93">93.</a><br><a name="94">94.</a><br><a name="95">95.</a><br><a name="96">96.</a><br><a name="97">97.</a><br><a name="98">98.</a><br><a name="99">99.</a><br><a name="100">100.</a><br><a name="101">101.</a><br><a name="102">102.</a><br><a name="103">103.</a><br><a name="104">104.</a><br><a name="105">105.</a><br><a name="106">106.</a><br><a name="107">107.</a><br><a name="108">108.</a><br><a name="109">109.</a><br><a name="110">110.</a><br><a name="111">111.</a><br><a name="112">112.</a><br><a name="113">113.</a><br><a name="114">114.</a><br><a name="115">115.</a><br><a name="116">116.</a><br><a name="117">117.</a><br><a name="118">118.</a><br><a name="119">119.</a><br><a name="120">120.</a><br><a name="121">121.</a><br><a name="122">122.</a><br><a name="123">123.</a><br><a name="124">124.</a><br><a name="125">125.</a><br><a name="126">126.</a><br><a name="127">127.</a><br><a name="128">128.</a><br><a name="129">129.</a><br><a name="130">130.</a><br><a name="131">131.</a><br><a name="132">132.</a><br><a name="133">133.</a><br><a name="134">134.</a><br><a name="135">135.</a><br><a name="136">136.</a><br><a name="137">137.</a><br><a name="138">138.</a><br><a name="139">139.</a><br><a name="140">140.</a><br><a name="141">141.</a><br><a name="142">142.</a><br><a name="143">143.</a><br><a name="144">144.</a><br><a name="145">145.</a><br><a name="146">146.</a><br><a name="147">147.</a><br><a name="148">148.</a><br><a name="149">149.</a><br><a name="150">150.</a><br><a name="151">151.</a><br><a name="152">152.</a><br><a name="153">153.</a><br><a name="154">154.</a><br><a name="155">155.</a><br><a name="156">156.</a><br><a name="157">157.</a><br><a name="158">158.</a><br><a name="159">159.</a><br><a name="160">160.</a><br><a name="161">161.</a><br><a name="162">162.</a><br><a name="163">163.</a><br><a name="164">164.</a><br><a name="165">165.</a><br><a name="166">166.</a><br><a name="167">167.</a><br><a name="168">168.</a><br><a name="169">169.</a><br><a name="170">170.</a><br><a name="171">171.</a><br><a name="172">172.</a><br><a name="173">173.</a><br><a name="174">174.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@ECHO OFF</span><br> <span style="color=#000000"><span class="c_cmmt">REM.-- Prepare the Command Processor</span></span><br> <span style="color=#000000">SETLOCAL ENABLEEXTENSIONS</span><br> <span style="color=#000000">SETLOCAL ENABLEDELAYEDEXPANSION</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM.-- Version History --</span></span><br> <span style="color=#000000"><span class="c_cmmt">REM XX.XXX YYYYMMDD Author Description</span></span><br> <span style="color=#000000">SET version=01.000-beta &<span class="c_cmmt">rem 20051201 p.h. initial version, providing the framework</span></span><br> <span style="color=#000000"><span class="c_cmmt">REM !! For a new version entry, copy the last entry down and modify Date, Author and Description</span></span><br> <span style="color=#000000">SET version=%version: =%</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM.-- Set the window title</span></span><br> <span style="color=#000000">SET title=<span class="c_pvar">%~n0</span></span><br> <span style="color=#000000">TITLE %title%</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM.--initialize the variables</span></span><br> <span style="color=#000000">set FilePersist=<span class="c_pvar">%~dpn0</span>+.cmd& <span class="c_cmmt">rem --define the filename where persistent variables get stored</span></span><br> <span style="color=#000000">set SvrCli_choice=,Server,Client,</span><br> <span style="color=#000000">call:setPersist SvrCli=Server</span><br> <span style="color=#000000">set bShowReadMe_choice=,Yes,No,</span><br> <span style="color=#000000">call:setPersist bShowReadMe=No</span><br> <span style="color=#000000">set InstSize_choice=,Full,Regular,Mini,</span><br> <span style="color=#000000">call:setPersist InstSize=Full</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">rem.--read the persistent variables from the storage</span></span><br> <span style="color=#000000">call:restorePersistentVars "%FilePersist%"</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menuLOOP">:menuLOOP</a></span><span class="c_cmmt"></span></span><br> <span style="color=#000000">echo.</span><br> <span style="color=#000000">echo.= Menu =================================================</span><br> <span style="color=#000000">echo.</span><br> <span style="color=#000000">for /f "tokens=1,2,* delims=_ " <span class="c_pvar">%%A</span> in ('"findstr /b /c:":menu_" "<span class="c_pvar">%~f0</span>""') do echo. <span class="c_pvar">%%B</span> <span class="c_pvar">%%C</span></span><br> <span style="color=#000000">set choice=</span><br> <span style="color=#000000">echo.&set /p choice=Make a choice or hit ENTER to quit: ||(</span><br> <span style="color=#000000"> call:savePersistentVars "%FilePersist%"& <span class="c_cmmt">rem --save the persistent variables to the storage</span></span><br> <span style="color=#000000"> GOTO:EOF</span><br> <span style="color=#000000">)</span><br> <span style="color=#000000">echo.&call:menu_%choice%</span><br> <span style="color=#000000">GOTO:menuLOOP</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">::-----------------------------------------------------------</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: menu functions follow below here</span></span><br> <span style="color=#000000"><span class="c_cmmt">::-----------------------------------------------------------</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menu_Options">:menu_Options</a></span><span class="c_cmmt">:</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menu_1">:menu_1</a></span><span class="c_cmmt"> Install version : '!SvrCli!' [!SvrCli_choice:~1,-1!]</span></span><br> <span style="color=#000000">call:getNextInList SvrCli "!SvrCli_choice!"</span><br> <span style="color=#000000">cls</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menu_2">:menu_2</a></span><span class="c_cmmt"> Size of installation : '!InstSize!' [!InstSize_choice:~1,-1!]</span></span><br> <span style="color=#000000">call:getNextInList InstSize "!InstSize_choice!"</span><br> <span style="color=#000000">cls</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menu_3">:menu_3</a></span><span class="c_cmmt"> Show Readme.txt when finished: '!bShowReadMe!' [!bShowReadMe_choice:~1,-1!]</span></span><br> <span style="color=#000000">call:getNextInList bShowReadMe "!bShowReadMe_choice!"</span><br> <span style="color=#000000">cls</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menu_">:menu_</a></span><span class="c_cmmt"></span></span><br> <span style="color=#000000"><span class="c_labl"><a name="menu_Execute">:menu_Execute</a></span><span class="c_cmmt">:</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menu_I">:menu_I</a></span><span class="c_cmmt"> Start Installation (simulation only)</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000">set maxcnt=20</span><br> <span style="color=#000000">if /i "%InstSize:~0,1%"=="F" set maxcnt=11</span><br> <span style="color=#000000">if /i "%InstSize:~0,1%"=="R" set maxcnt=7</span><br> <span style="color=#000000">if /i "%InstSize:~0,1%"=="M" set maxcnt=3</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">echo.Simulating an installation for !maxcnt! files...</span><br> <span style="color=#000000">call:initProgress maxcnt</span><br> <span style="color=#000000">for /l <span class="c_pvar">%%C</span> in (1,1,!maxcnt!) do (</span><br> <span style="color=#000000"> echo.Pretend to install !SvrCli! file <span class="c_pvar">%%C</span>.</span><br> <span style="color=#000000"> call:sleep 1</span><br> <span style="color=#000000"> call:doProgress</span><br> <span style="color=#000000">)</span><br> <span style="color=#000000">call:sleep 1</span><br> <span style="color=#000000">TITLE %title%</span><br> <span style="color=#000000">if /i "%bShowReadMe:~0,1%"=="Y" notepad ReadMe.txt</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menu_C">:menu_C</a></span><span class="c_cmmt"> Clear Screen</span></span><br> <span style="color=#000000">cls</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">::-----------------------------------------------------------</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: helper functions follow below here</span></span><br> <span style="color=#000000"><span class="c_cmmt">::-----------------------------------------------------------</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="setPersist">:setPersist</a></span><span class="c_cmmt"> -- to be called to initialize persistent variables</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- %*: set command arguments</span></span><br> <span style="color=#000000">set %*</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="getPersistentVars">:getPersistentVars</a></span><span class="c_cmmt"> -- returns a comma separated list of persistent variables</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- <span class="c_pvar">%~1</span>: reference to return variable</span></span><br> <span style="color=#000000">SETLOCAL</span><br> <span style="color=#000000">set retlist=</span><br> <span style="color=#000000">set parse=findstr /i /c:"call:setPersist" "<span class="c_pvar">%~f0</span>%"^|find /v "ButNotThisLine"</span><br> <span style="color=#000000">for /f "tokens=2 delims== " <span class="c_pvar">%%a</span> in ('"%parse%"') do (set retlist=!retlist!<span class="c_pvar">%%a</span>,)</span><br> <span style="color=#000000">( ENDLOCAL & <span class="c_cmmt">REM RETURN VALUES</span></span><br> <span style="color=#000000"> IF "<span class="c_pvar">%~1</span>" NEQ "" SET <span class="c_pvar">%~1</span>=%retlist%</span><br> <span style="color=#000000">)</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="savePersistentVars">:savePersistentVars</a></span><span class="c_cmmt"> -- Save values of persistent variables into a file</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- <span class="c_pvar">%~1</span>: file name</span></span><br> <span style="color=#000000">SETLOCAL</span><br> <span style="color=#000000">echo.>"<span class="c_pvar">%~1</span>"</span><br> <span style="color=#000000">call :getPersistentVars persvars</span><br> <span style="color=#000000">for <span class="c_pvar">%%a</span> in (%persvars%) do (echo.SET <span class="c_pvar">%%a</span>=!<span class="c_pvar">%%a</span>!>>"<span class="c_pvar">%~1</span>")</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="restorePersistentVars">:restorePersistentVars</a></span><span class="c_cmmt"> -- Restore the values of the persistent variables</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- <span class="c_pvar">%~1</span>: batch file name to restore from</span></span><br> <span style="color=#000000">if exist "%FilePersist%" call "%FilePersist%"</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="getNextInList">:getNextInList</a></span><span class="c_cmmt"> -- return next value in list</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- <span class="c_pvar">%~1</span> - in/out ref to current value, returns new value</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- <span class="c_pvar">%~2</span> - in choice list, must start with delimiter which must not be '@'</span></span><br> <span style="color=#000000">SETLOCAL</span><br> <span style="color=#000000">set lst=<span class="c_pvar">%~2</span>& <span class="c_cmmt">rem.-- get the choice list</span></span><br> <span style="color=#000000">if "%lst:~0,1%" NEQ "%lst:~-1%" echo.ERROR Choice list must start and end with the delimiter&GOTO:EOF</span><br> <span style="color=#000000">set dlm=%lst:~-1%& <span class="c_cmmt">rem.-- extract the delimiter used</span></span><br> <span style="color=#000000">set old=!<span class="c_pvar">%~1</span>!& <span class="c_cmmt">rem.-- get the current value</span></span><br> <span style="color=#000000">set fst=&for /f "delims=%dlm%" <span class="c_pvar">%%a</span> in ("%lst%") do set fst=<span class="c_pvar">%%a</span>&<span class="c_cmmt">rem.--get the first entry</span></span><br> <span style="color=#000000"> <span class="c_cmmt">rem.-- replace the current value with a @, append the first value</span></span><br> <span style="color=#000000">set lll=!lst:%dlm<span class="c_pvar">%%o</span>ld<span class="c_pvar">%%d</span>lm%=%dlm%@%dlm%!%fst<span class="c_pvar">%%d</span>lm%</span><br> <span style="color=#000000"> <span class="c_cmmt">rem.-- get the string after the @</span></span><br> <span style="color=#000000">for /f "tokens=2 delims=@" <span class="c_pvar">%%a</span> in ("%lll%") do set lll=<span class="c_pvar">%%a</span></span><br> <span style="color=#000000"> <span class="c_cmmt">rem.-- extract the next value</span></span><br> <span style="color=#000000">for /f "delims=%dlm%" <span class="c_pvar">%%a</span> in ("%lll%") do set new=<span class="c_pvar">%%a</span></span><br> <span style="color=#000000">( ENDLOCAL & <span class="c_cmmt">REM RETURN VALUES</span></span><br> <span style="color=#000000"> IF "<span class="c_pvar">%~1</span>" NEQ "" (SET <span class="c_pvar">%~1</span>=%new%) ELSE (echo.%new%)</span><br> <span style="color=#000000">)</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="initProgress">:initProgress</a></span><span class="c_cmmt"> -- initialize an internal progress counter and display the progress in percent</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- <span class="c_pvar">%~1</span>: in - progress counter maximum, equal to 100 percent</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- <span class="c_pvar">%~2</span>: in - title string formatter, default is '[P] completed.'</span></span><br> <span style="color=#000000">set /a ProgressCnt=-1</span><br> <span style="color=#000000">set /a ProgressMax=<span class="c_pvar">%~1</span></span><br> <span style="color=#000000">set ProgressFormat=<span class="c_pvar">%~2</span></span><br> <span style="color=#000000">if "%ProgressFormat%"=="" set ProgressFormat=[PPPP]</span><br> <span style="color=#000000">set ProgressFormat=!ProgressFormat:[PPPP]=[P] completed.!</span><br> <span style="color=#000000">call :doProgress</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="doProgress">:doProgress</a></span><span class="c_cmmt"> -- display the next progress tick</span></span><br> <span style="color=#000000">set /a ProgressCnt+=1</span><br> <span style="color=#000000">SETLOCAL</span><br> <span style="color=#000000">set /a per=100*ProgressCnt/ProgressMax</span><br> <span style="color=#000000">set per=!per!%%</span><br> <span style="color=#000000">title %ProgressFormat:[P]=!per!%</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="sleep">:sleep</a></span><span class="c_cmmt"> -– waits some seconds before returning</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- <span class="c_pvar">%~1</span> – in, number of seconds to wait</span></span><br> <span style="color=#000000">FOR /l <span class="c_pvar">%%a</span> in (<span class="c_pvar">%~1</span>,-1,1) do (ping -n 2 -w 1 127.0.0.1>NUL)</span><br> <span style="color=#000000">goto :eof</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>= Menu ================================================= Options: 1 Install version : 'Client' [Server,Client] 2 Size of installation : 'Full' [Full,Regular,Mini] 3 Show Readme.txt when finished: 'No' [Yes,No] Execute: I Start Installation (simulation only) C Clear Screen Make a choice or hit ENTER to quit: </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name="_Toc145951133"></a> <a name="Batch.AdvancedTemplate"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>DOS Batch - Advanced Template - Template with version history, window title, delayed automatic exit</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">This advanced batch template features: <ul> <li>Initialization of the command processor </li> <li>Version History for manual script change tracking</li> <li>Window title of choice</li> <li>Delayed exit for unattended completion</li> </ul></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchDelayOnExit.bat">BatchDelayOnExit.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br><a name="12">12.</a><br><a name="13">13.</a><br><a name="14">14.</a><br><a name="15">15.</a><br><a name="16">16.</a><br><a name="17">17.</a><br><a name="18">18.</a><br><a name="19">19.</a><br><a name="20">20.</a><br><a name="21">21.</a><br><a name="22">22.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@ECHO OFF</span><br> <span style="color=#000000"><span class="c_cmmt">REM.-- Prepare the Command Processor</span></span><br> <span style="color=#000000">SETLOCAL ENABLEEXTENSIONS</span><br> <span style="color=#000000">SETLOCAL ENABLEDELAYEDEXPANSION</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM.-- Version History --</span></span><br> <span style="color=#000000"><span class="c_cmmt">REM XX.XXX YYYYMMDD Author Description</span></span><br> <span style="color=#000000">SET version=01.000-beta &<span class="c_cmmt">rem 20051201 p.h. initial version, providing the framework</span></span><br> <span style="color=#000000"><span class="c_cmmt">REM !! For a new version entry, copy the last entry down and modify Date, Author and Description</span></span><br> <span style="color=#000000">SET version=%version: =%</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM.-- Set the window title</span></span><br> <span style="color=#000000">SET title=<span class="c_pvar">%~n0</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM.-- your code goes here</span></span><br> <span style="color=#000000">echo.Hello World</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM.-- End of application</span></span><br> <span style="color=#000000">FOR /l <span class="c_pvar">%%a</span> in (5,-1,1) do (TITLE %title% -- closing in <span class="c_pvar">%%a</span>s&ping -n 2 -w 1 127.0.0.1>NUL)</span><br> <span style="color=#000000">TITLE Press any key to close the application&ECHO.&GOTO:EOF</span><br> </code></td> </tr></tbody></table> </td> </tr> </tbody></table> <hr> <a name="_Toc145951141"></a> <a name="Batch.FileList"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>DOS Batch - File Search List - Quickly find a file on your hard drive</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>This batch creates a lookup list of all files on the C: drive. <br>When running the batch the first time type a hyphen in order to build the lookup list first. </p> Features: <ul> <li>The lookup list will be appended to the batch file itself.</li> <li>Options: build/rebuild lookup list, or locate a file</li> <li>Regular expressions are supported, see <a href="http://www.dostips.com/DosCommandIndex.htm#FINDSTR">FINDSTR</a> for details.</li> </ul></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchListOfFiles.bat">BatchListOfFiles.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@<span class="c_cmmt">REM....&SETLOCAL ENABLEEXTENSIONS&SETLOCAL DISABLEDELAYEDEXPANSION</span></span><br> <span style="color=#000000">@<span class="c_cmmt">REM....&set /p s=FileSearch, type '-' to refresh lookup list: ||GOTO:EOF</span></span><br> <span style="color=#000000">@<span class="c_cmmt">REM....&if .%s% NEQ .- echo.&findstr %s% "<span class="c_pvar">%~f0</span>"&PAUSE&GOTO:EOF</span></span><br> <span style="color=#000000">@<span class="c_cmmt">REM....&findstr /b /c:"@REM....&" "<span class="c_pvar">%~f0</span>">"<span class="c_pvar">%~f0</span>.txt"</span></span><br> <span style="color=#000000">@<span class="c_cmmt">REM....&dir /s/b c:\ 1>>"<span class="c_pvar">%~f0</span>.txt"&move /Y "<span class="c_pvar">%~f0</span>.txt" "<span class="c_pvar">%~f0</span>"</span></span><br> <span style="color=#000000">@<span class="c_cmmt">REM....&GOTO:EOF</span></span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>FileSearch, type '-' to refresh lookup list: logoMed.gif C:\Python22\tcl\tk8.3\images\logoMed.gif Press any key to continue . . . </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name="_Toc145951140"></a> <a name="Batch.FindAndReplace"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2009-12-22</font></font></div> <h2>DOS Batch - Find and Replace - Search a file and replace all occurrences of a string with another string</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>This batch allows string substitution in a text file. It parses each line of a text file for a particular string and replaces it with another string. <br>I.e. To replace all occurrences of "Yellow Submarine" in "color.txt" with "uboot" and put the output on the screen run: <br><b>BatchSubstitute.bat "Yellow Submarine" uboot color.txt</b> <br>Or <br><b>type color.txt|BatchSubstitute.bat "Yellow Submarine" uboot</b> <br> <br>Optionally pipe the output into a new file, i.e. <br><b>BatchSubstitute.bat "Yellow Submarine" uboot color.txt>newfile.txt</b> <br>Or <br><b>type color.txt|BatchSubstitute.bat "Yellow Submarine" uboot>newfile.txt</b> </p> Note: Due to the nature of the FOR command and string substitution, the following known restrictions apply: <ul> <li>Lines starting with "]" character will end up empty</li> <li>OldStr must not start with "*"</li> <li>Lines must not contain any of the following characters within a quoted string: "&<>|^", as discussed in this <a href="http://www.dostips.com/forum/viewtopic.php?p=2600&highlight=#2600">post</a>.</li> </ul></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchSubstitute.bat">BatchSubstitute.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br><a name="12">12.</a><br><a name="13">13.</a><br><a name="14">14.</a><br><a name="15">15.</a><br><a name="16">16.</a><br><a name="17">17.</a><br><a name="18">18.</a><br><a name="19">19.</a><br><a name="20">20.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@echo off</span><br> <span style="color=#000000"><span class="c_cmmt">REM -- Prepare the Command Processor --</span></span><br> <span style="color=#000000">SETLOCAL ENABLEEXTENSIONS</span><br> <span style="color=#000000">SETLOCAL DISABLEDELAYEDEXPANSION</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">::BatchSubstitude - parses a File line by line and replaces a substring"</span></span><br> <span style="color=#000000"><span class="c_cmmt">::syntax: BatchSubstitude.bat OldStr NewStr File</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: OldStr [in] - string to be replaced</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: NewStr [in] - string to replace with</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: File [in] - file to be parsed</span></span><br> <span style="color=#000000">:$changed 20100115</span><br> <span style="color=#000000">:$source http://www.dostips.com</span><br> <span style="color=#000000">if "<span class="c_pvar">%~1</span>"=="" findstr "^<span class="c_cmmt">::" "<span class="c_pvar">%~f0</span>"&GOTO:EOF</span></span><br> <span style="color=#000000">for /f "tokens=1,* delims=]" <span class="c_pvar">%%A</span> in ('"type %3|find /n /v """') do (</span><br> <span style="color=#000000"> set "line=<span class="c_pvar">%%B</span>"</span><br> <span style="color=#000000"> if defined line (</span><br> <span style="color=#000000"> call set "line=echo.<span class="c_pvar">%%l</span>ine:<span class="c_pvar">%~1</span>=<span class="c_pvar">%~2</span>%%"</span><br> <span style="color=#000000"> for /f "delims=" <span class="c_pvar">%%X</span> in ('"echo."<span class="c_pvar">%%l</span>ine%%""') do <span class="c_pvar">%%~X</span></span><br> <span style="color=#000000"> ) ELSE echo.</span><br> <span style="color=#000000">)</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>C:>type BatchSubstitute.txt !!! THIS TEST DOESN`T REPLACE ANYTHING, IT JUST MAKES SURE !!! THE SCRIPT WORKS FOR SPECIAL CHARACTERS. !!! THE SCRIPT WOULD NOT WORK IF ANY OF THE CHARACTERs &<>|^ WOULD !!! APPEAR WITHIN A QUOTED STRING Next line is empty this > is a grater-than character this < is a less-than character this ( is a opening bracket character this ) is a closing bracket character this % is a percent character this & is an ampersand character this ! is an exclamation character this " is a quote character this | is a vertical character this ^ is a up character this is a "quoted string" this is a %percented string% this is a !exclamationed string! a "quoted ( opening bracket" a "quoted ) closing bracket" a "quoted % quote character" a "quoted ! quote character" a "quoted " quote character" C:>BatchSubstitute.bat Oldtext Newtext BatchSubstitute.txt !!! THIS TEST DOESN`T REPLACE ANYTHING, IT JUST MAKES SURE !!! THE SCRIPT WORKS FOR SPECIAL CHARACTERS. !!! THE SCRIPT WOULD NOT WORK IF ANY OF THE CHARACTERs &<>|^ WOULD !!! APPEAR WITHIN A QUOTED STRING Next line is empty this > is a grater-than character this < is a less-than character this ( is a opening bracket character this ) is a closing bracket character this % is a percent character this & is an ampersand character this ! is an exclamation character this " is a quote character this | is a vertical character this ^ is a up character this is a "quoted string" this is a %percented string% this is a !exclamationed string! a "quoted ( opening bracket" a "quoted ) closing bracket" a "quoted % quote character" a "quoted ! quote character" a "quoted " quote character" </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Batch.DeletePrintJobs"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2010-04-18</font></font></div> <h2>DOS Batch - Force Delete All Print Jobs - Get rid of these pesky print jobs</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>Did you ever pull the paper out of your printer to stop it from printing? Then surly next thing you did was power cycling the printer to empty the printer buffer and then cancelling the print job from the printer spooler on your PC. The print job sometimes remains a long time in the printer queue before finally disappearing and allowing the next print job to be processed. This is annoying on my box it takes up to 5 minutes. Even rebooting the PC doesn`t help as it doesn`t empty the printer spooler.</p> <p>This little batch gets it done. It temporarily stops the spooler service and removes all files from the printer queue. <b>Beware though that all printer jobs will be deleted, not only the ones that got canceled</b>. </p></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchDeleteAllPrintJobs.bat">BatchDeleteAllPrintJobs.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@echo off</span><br> <span style="color=#000000">:$reference http://www.dostips.com/</span><br> <span style="color=#000000">:$reference http://support.microsoft.com/kb/946737</span><br> <span style="color=#000000">net stop spooler</span><br> <span style="color=#000000">del "%systemroot%\system32\spool\printers\*.shd"</span><br> <span style="color=#000000">del "%systemroot%\system32\spool\printers\*.spl"</span><br> <span style="color=#000000">net start spooler</span><br> <span style="color=#000000">pause</span><br> </code></td> </tr></tbody></table> </td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Batch.Progress"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-03-29</font></font></div> <h2>DOS Batch - Progress - Show progress in batch using the title bar</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">Showing progress in the output window seems impractical in DOS batch, since there is no way to overwrite a previews output for an updated progress status during each progress tick. Using the <a href="http://www.dostips.com/DosCommandIndex.htm#ECHO">ECHO</a> command is not nice, screen content quickly scrolls out of sight. A practicable alternative may be to use the window <a href="http://www.dostips.com/DosCommandIndex.htm#TITLE">TITLE</a> for the progress message. A nice side effect is that you can minimize the batch window and still observe the progress output in the task bar, since the task bar text will always reflect the window title text.</td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/DosProgress.bat">DosProgress.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br><a name="12">12.</a><br><a name="13">13.</a><br><a name="14">14.</a><br><a name="15">15.</a><br><a name="16">16.</a><br><a name="17">17.</a><br><a name="18">18.</a><br><a name="19">19.</a><br><a name="20">20.</a><br><a name="21">21.</a><br><a name="22">22.</a><br><a name="23">23.</a><br><a name="24">24.</a><br><a name="25">25.</a><br><a name="26">26.</a><br><a name="27">27.</a><br><a name="28">28.</a><br><a name="29">29.</a><br><a name="30">30.</a><br><a name="31">31.</a><br><a name="32">32.</a><br><a name="33">33.</a><br><a name="34">34.</a><br><a name="35">35.</a><br><a name="36">36.</a><br><a name="37">37.</a><br><a name="38">38.</a><br><a name="39">39.</a><br><a name="40">40.</a><br><a name="41">41.</a><br><a name="42">42.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@ECHO OFF</span><br> <span style="color=#000000">set "max=11"</span><br> <span style="color=#000000">call :initProgress %max% "Window Title: [PPP]"</span><br> <span style="color=#000000">for /l <span class="c_pvar">%%N</span> in (1,1,%max%) do (</span><br> <span style="color=#000000"> ping -n 2 -w 1 127.0.0.1>NUL</span><br> <span style="color=#000000"> call:doProgress</span><br> <span style="color=#000000">)</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="initProgress">:initProgress</a></span><span class="c_cmmt"> max format -- initialize an internal progress counter and display the progress in percent</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- max [in] - progress counter maximum, equal to 100 percent</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- format [in,opt] - title string formatter, default is '[P] completed.'</span></span><br> <span style="color=#000000">:$created 20060101 :$changed 20080327</span><br> <span style="color=#000000">:$source http://www.dostips.com</span><br> <span style="color=#000000">set /a "ProgressCnt=-1"</span><br> <span style="color=#000000">set /a "ProgressMax=<span class="c_pvar">%~1</span>"</span><br> <span style="color=#000000">set "ProgressFormat=<span class="c_pvar">%~2</span>"</span><br> <span style="color=#000000">if not defined ProgressFormat set "ProgressFormat=[PPPP]"</span><br> <span style="color=#000000">set "ProgressFormat=%ProgressFormat:[PPPP]=[P] completed.%"</span><br> <span style="color=#000000">call:doProgress</span><br> <span style="color=#000000">EXIT /b</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="doProgress">:doProgress</a></span><span class="c_cmmt"> -- display the next progress tick</span></span><br> <span style="color=#000000">:$created 20060101 :$changed 20080327</span><br> <span style="color=#000000">:$source http://www.dostips.com</span><br> <span style="color=#000000">set /a "ProgressCnt+=1"</span><br> <span style="color=#000000">SETLOCAL ENABLEDELAYEDEXPANSION</span><br> <span style="color=#000000">set /a "per100=100*ProgressCnt/ProgressMax"</span><br> <span style="color=#000000">set /a "per10=per100/10"</span><br> <span style="color=#000000">set /a "per10m=10-per100/10-1"</span><br> <span style="color=#000000">set "P=%per100%%%"</span><br> <span style="color=#000000">set "PP="</span><br> <span style="color=#000000">for /l <span class="c_pvar">%%N</span> in (0,1,%per10%) do call set "PP=<span class="c_pvar">%%P</span>P%%*"</span><br> <span style="color=#000000">for /l <span class="c_pvar">%%N</span> in (%per10%,1,9) do call set "PP=<span class="c_pvar">%%P</span>P%% "</span><br> <span style="color=#000000">set "PPP="</span><br> <span style="color=#000000">for /l <span class="c_pvar">%%N</span> in (0,1,%per10m%) do call set "PPP=<span class="c_pvar">%%P</span>PP%%*"</span><br> <span style="color=#000000">set "ProgressFormat=%ProgressFormat:[P]=!P!%"</span><br> <span style="color=#000000">set "ProgressFormat=%ProgressFormat:[PP]=!PP!%"</span><br> <span style="color=#000000">set "ProgressFormat=%ProgressFormat:[PPP]=!PPP!%"</span><br> <span style="color=#000000">title %ProgressFormat%</span><br> <span style="color=#000000">EXIT /b</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Output:</td> <td class="text" valign="top"><img src="DOS%20Batch%20-%20Advanced%20Template_files/DtAnimProgress.GIF"></td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Quine.Quine_1_3"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-11-13</font></font></div> <h2>DOS Batch - Quine 109 bytes - A pretty short DOS Batch Quine</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">A Quine is a program who`s only output is it`s program code. <br>Run the Quine using the following command in order to make sure <a href="http://www.dostips.com/DosCommandIndex.htm#SETLOCAL">Delayed Expansion</a> is disabled and <a href="http://www.dostips.com/DosCommandIndex.htm#ECHO">ECHO</a> is OFF: <br>C:> Cmd /Q /V:Off /C BatchQuine.bat <br><b>If you use this code make sure to add a reference to DosTips.com.</b></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchQuine_1_3.bat">BatchQuine_1_3.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">Set "T=Echo Set "T=!T!"&Call Echo Set E=!E!E!E!!E!E!E!&Echo Cmd/V:On/C"!E!T!E!""</span><br> <span style="color=#000000">Set E=%%</span><br> <span style="color=#000000">Cmd/V:On/C"%T%"</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>Set "T=Echo Set "T=!T!"&Call Echo Set E=!E!E!E!!E!E!E!&Echo Cmd/V:On/C"!E!T!E!"" Set E=%% Cmd/V:On/C"%T%" </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Quine.Quine_2_2"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-11-13</font></font></div> <h2>DOS Batch - Quine 134 bytes - A pretty short DOS Batch Quine</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">A Quine is a program who`s only output is it`s program code. <br>This little Quine has been developed by Peter Hartmann. Run the Quine using the following command in order to make sure <a href="http://www.dostips.com/DosCommandIndex.htm#SETLOCAL">Delayed Expansion</a> is disabled and <a href="http://www.dostips.com/DosCommandIndex.htm#ECHO">ECHO</a> is OFF: <br>C:> Cmd /Q /V:Off /C BatchQuine.bat <br><b>If you use this code make sure to add a reference to DosTips.com.</b></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchQuine_2_2.bat">BatchQuine_2_2.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">Set "T=Echo Set "T=!T!"&Echo Set "U=!U!""</span><br> <span style="color=#000000">Set "U=Echo Cmd/V:On/CCmd/V:On/C!T!&Cmd/V:On/C!U!"</span><br> <span style="color=#000000">Cmd/V:On/CCmd/V:On/C!T!&Cmd/V:On/C!U!</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>Set "T=Echo Set "T=!T!"&Echo Set "U=!U!"" Set "U=Echo Cmd/V:On/CCmd/V:On/C!T!&Cmd/V:On/C!U!" Cmd/V:On/CCmd/V:On/C!T!&Cmd/V:On/C!U! </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Quine.Quine_1_1_1"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-11-13</font></font></div> <h2>DOS Batch - Quine 159 bytes - A pretty short DOS Batch Quine</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">A Quine is a program who`s only output is it`s program code. <br>Run the Quine using the following command in order to make sure <a href="http://www.dostips.com/DosCommandIndex.htm#SETLOCAL">Delayed Expansion</a> is disabled and <a href="http://www.dostips.com/DosCommandIndex.htm#ECHO">ECHO</a> is OFF: <br>C:> Cmd /Q /V:Off /C BatchQuine.bat <br><b>If you use this code make sure to add a reference to DosTips.com.</b></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchQuine_1_1_1.bat">BatchQuine_1_1_1.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">Set "T=Echo Set "T=!T!"&Call Echo Set "E=!E!E!E!!E!E!E!"&Echo Setlocal Enabledelayedexpansion&Echo !E!T!E!"</span><br> <span style="color=#000000">Set "E=%%"</span><br> <span style="color=#000000">Setlocal Enabledelayedexpansion</span><br> <span style="color=#000000">%T%</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>Set "T=Echo Set "T=!T!"&Call Echo Set "E=!E!E!E!!E!E!E!"&Echo Setlocal Enabledelayedexpansion&Echo !E!T!E!" Set "E=%%" Setlocal Enabledelayedexpansion %T% </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Quine.Quine_1_2"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-11-13</font></font></div> <h2>DOS Batch - Quine 259 bytes - A DOS Batch Quine that makes no assumption</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">A Quine is a program who`s only output is it`s program code. <br>This little Quine has been developed by Peter Hartmann. <br><b>If you use this code make sure to add a reference to DosTips.com.</b></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchQuine_1_2.bat">BatchQuine_1_2.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@Set "Src=www.Dostips.com"</span><br> <span style="color=#000000">@Setlocal Disabledelayedexpansion</span><br> <span style="color=#000000">@Set "T=Echo @Set "Src=www.Dostips.com"&Echo @Setlocal Disabledelayedexpansion&Echo @Set "T=!T!"&Call Echo @Set "E=!E!E!E!!E!E!E!"&Echo @Cmd /V:On /C "!E!T!E!""</span><br> <span style="color=#000000">@Set "E=%%"</span><br> <span style="color=#000000">@Cmd /V:On /C "%T%"</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>@Set "Src=www.Dostips.com" @Setlocal Disabledelayedexpansion @Set "T=Echo @Set "Src=www.Dostips.com"&Echo @Setlocal Disabledelayedexpansion&Echo @Set "T=!T!"&Call Echo @Set "E=!E!E!E!!E!E!E!"&Echo @Cmd /V:On /C "!E!T!E!"" @Set "E=%%" @Cmd /V:On /C "%T%" </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Quine.Quine_1_1"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-11-13</font></font></div> <h2>DOS Batch - Quine 301 bytes - A DOS Batch Quine that makes no assumption</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">A Quine is a program who`s only output is it`s program code. <br>This little Quine has been developed by Peter Hartmann. <br><b>If you use this code make sure to add a reference to DosTips.com.</b></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchQuine_1_1.bat">BatchQuine_1_1.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@Set "Src=www.Dostips.com"</span><br> <span style="color=#000000">@Setlocal Disabledelayedexpansion</span><br> <span style="color=#000000">@Set "T=Echo @Set "Src=www.Dostips.com"&Echo @Setlocal Disabledelayedexpansion&Echo @Set "T=!T!"&Call Echo @Set "E=!E!E!E!!E!E!E!"&Echo @Setlocal Enabledelayedexpansion&Echo @!E!T!E!"</span><br> <span style="color=#000000">@Set "E=%%"</span><br> <span style="color=#000000">@Setlocal Enabledelayedexpansion</span><br> <span style="color=#000000">@%T%</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>@Set "Src=www.Dostips.com" @Setlocal Disabledelayedexpansion @Set "T=Echo @Set "Src=www.Dostips.com"&Echo @Setlocal Disabledelayedexpansion&Echo @Set "T=!T!"&Call Echo @Set "E=!E!E!E!!E!E!E!"&Echo @Setlocal Enabledelayedexpansion&Echo @!E!T!E!" @Set "E=%%" @Setlocal Enabledelayedexpansion @%T% </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Quine.Quine_2_1"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-11-13</font></font></div> <h2>DOS Batch - Quine 308 bytes - A DOS Batch Quine that makes no assumption</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">A Quine is a program who`s only output is it`s program code. <br>This little Quine has been developed by Peter Hartmann. <br><b>If you use this code make sure to add a reference to DosTips.com.</b></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchQuine_2_1.bat">BatchQuine_2_1.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@Echo Off</span><br> <span style="color=#000000">Set "Src=www.Dostips.com"</span><br> <span style="color=#000000">Setlocal Disabledelayedexpansion</span><br> <span style="color=#000000">Set "T=Echo @Echo Off&Echo Set "Src=www.Dostips.com"&Echo Setlocal Disabledelayedexpansion&Echo Set "T=!T!"&Echo Set "U=!U!""</span><br> <span style="color=#000000">Set "U=Echo Cmd /V:On /C Cmd /V:On /C !T!&Cmd /V:On /C !U!"</span><br> <span style="color=#000000">Cmd /V:On /C Cmd /V:On /C !T!&Cmd /V:On /C !U!</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>@Echo Off Set "Src=www.Dostips.com" Setlocal Disabledelayedexpansion Set "T=Echo @Echo Off&Echo Set "Src=www.Dostips.com"&Echo Setlocal Disabledelayedexpansion&Echo Set "T=!T!"&Echo Set "U=!U!"" Set "U=Echo Cmd /V:On /C Cmd /V:On /C !T!&Cmd /V:On /C !U!" Cmd /V:On /C Cmd /V:On /C !T!&Cmd /V:On /C !U! </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Quine.Shortest"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-11-13</font></font></div> <h2>DOS Batch - Shortest Quine 109 Bytes - Likely the shortest DOS Batch Quine ever</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">A Quine is a program who`s only output is it`s program code. <br>Run the Quine using the following command in order to make sure <a href="http://www.dostips.com/DosCommandIndex.htm#SETLOCAL">Delayed Expansion</a> is disabled and <a href="http://www.dostips.com/DosCommandIndex.htm#ECHO">ECHO</a> is OFF: <br>C:> Cmd /Q /V:Off /C BatchQuine.bat <br><b>If you use this code make sure to add a reference to DosTips.com.</b></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchQuine_1_3.bat">BatchQuine_1_3.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">Set "T=Echo Set "T=!T!"&Call Echo Set E=!E!E!E!!E!E!E!&Echo Cmd/V:On/C"!E!T!E!""</span><br> <span style="color=#000000">Set E=%%</span><br> <span style="color=#000000">Cmd/V:On/C"%T%"</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>Set "T=Echo Set "T=!T!"&Call Echo Set E=!E!E!E!!E!E!E!&Echo Cmd/V:On/C"!E!T!E!"" Set E=%% Cmd/V:On/C"%T%" </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Batch.Menu"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>DOS Batch - Simple Menu - Simple menu framework. Plug in a new menu item and coresponding script as single function block</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>This simple <b>menu framework</b> parses itself for batch labels of certain signature and lists them as menu items. The self-parsing feature makes the menu generic. New menu items can be inserted by adding new function blocks without changing the menu infrastructure. </p> Features: <ul> <li>simple and well structured</li> <li>easy to enhance</li> <li>easy to maintain</li> </ul></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchMenu.bat">BatchMenu.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br><a name="12">12.</a><br><a name="13">13.</a><br><a name="14">14.</a><br><a name="15">15.</a><br><a name="16">16.</a><br><a name="17">17.</a><br><a name="18">18.</a><br><a name="19">19.</a><br><a name="20">20.</a><br><a name="21">21.</a><br><a name="22">22.</a><br><a name="23">23.</a><br><a name="24">24.</a><br><a name="25">25.</a><br><a name="26">26.</a><br><a name="27">27.</a><br><a name="28">28.</a><br><a name="29">29.</a><br><a name="30">30.</a><br><a name="31">31.</a><br><a name="32">32.</a><br><a name="33">33.</a><br><a name="34">34.</a><br><a name="35">35.</a><br><a name="36">36.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@ECHO OFF</span><br> <span style="color=#000000"><span class="c_cmmt">REM.-- Prepare the Command Processor</span></span><br> <span style="color=#000000">SETLOCAL ENABLEEXTENSIONS</span><br> <span style="color=#000000">SETLOCAL ENABLEDELAYEDEXPANSION</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menuLOOP">:menuLOOP</a></span><span class="c_cmmt"></span></span><br> <span style="color=#000000">echo.</span><br> <span style="color=#000000">echo.= Menu =================================================</span><br> <span style="color=#000000">echo.</span><br> <span style="color=#000000">for /f "tokens=1,2,* delims=_ " <span class="c_pvar">%%A</span> in ('"findstr /b /c:":menu_" "<span class="c_pvar">%~f0</span>""') do echo. <span class="c_pvar">%%B</span> <span class="c_pvar">%%C</span></span><br> <span style="color=#000000">set choice=</span><br> <span style="color=#000000">echo.&set /p choice=Make a choice or hit ENTER to quit: ||GOTO:EOF</span><br> <span style="color=#000000">echo.&call:menu_%choice%</span><br> <span style="color=#000000">GOTO:menuLOOP</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">::-----------------------------------------------------------</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: menu functions follow below here</span></span><br> <span style="color=#000000"><span class="c_cmmt">::-----------------------------------------------------------</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menu_1">:menu_1</a></span><span class="c_cmmt"> Have some fun</span></span><br> <span style="color=#000000">echo.Have some fun by adding some more code right here</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menu_2">:menu_2</a></span><span class="c_cmmt"> Get a water</span></span><br> <span style="color=#000000">echo.Get a water and then add some code right here</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menu_">:menu_</a></span><span class="c_cmmt"></span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menu_T">:menu_T</a></span><span class="c_cmmt"> Tip</span></span><br> <span style="color=#000000">echo.It's easy to add a line separator using one or more fake labels</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="menu_C">:menu_C</a></span><span class="c_cmmt"> Clear Screen</span></span><br> <span style="color=#000000">cls</span><br> <span style="color=#000000">GOTO:EOF</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>= Menu ================================================= 1 Have some fun 2 Get a water T Tip C Clear Screen Make a choice or hit ENTER to quit: </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name="_Toc145951142"></a> <a name="Batch.SortTextWithNumbers"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>DOS Batch - Sorting text with numbers - Sorting that handles numbers as numbers not text</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>This batch sort`s text by handling the first number found in each line as real number not as text.</p> E.g.: <ul> <li>In a text search 10 is less than 9, because the first letter 1 is less than 9</li> <li>In a number search 10 is greater than 9</li> </ul></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><a href="http://www.dostips.com/sortn.bat">sortn.bat</a></td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>Abc9def Abc10def </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name="_Toc145951131"></a> <a name="Batch.FunctionTemplate"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>DOS Function Template - A function template with all features of a true DOS function</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">The function template can be used as starting point for a new function. Complete the template into a useful function like this: <ul> <li>Rename the function</li> <li>Add proper description for the function and its arguments</li> <li>Fill in the function body</li> <li>Return desired values</li> </ul></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchFunctionTmpl.bat">BatchFunctionTmpl.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000"><span class="c_labl"><a name="myFunctionName">:myFunctionName</a></span><span class="c_cmmt"> -- function description here</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- <span class="c_pvar">%~1</span>: argument description here</span></span><br> <span style="color=#000000">SETLOCAL</span><br> <span style="color=#000000"><span class="c_cmmt">REM.--function body here</span></span><br> <span style="color=#000000">set LocalVar1=...</span><br> <span style="color=#000000">set LocalVar2=...</span><br> <span style="color=#000000">(ENDLOCAL & <span class="c_cmmt">REM -- RETURN VALUES</span></span><br> <span style="color=#000000"> IF "<span class="c_pvar">%~1</span>" NEQ "" SET <span class="c_pvar">%~1</span>=%LocalVar1%</span><br> <span style="color=#000000"> IF "<span class="c_pvar">%~2</span>" NEQ "" SET <span class="c_pvar">%~2</span>=%LocalVar2%</span><br> <span style="color=#000000">)</span><br> <span style="color=#000000">GOTO:EOF</span><br> </code></td> </tr></tbody></table> </td> </tr> </tbody></table> <hr> <a name="_Toc145951134"></a> <a name="Batch.CommandIndex"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>DOS Help File Builder - Command reference in HTML format via batch</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>A DOS batch that creates a well formatted HTML file listing the help output for all DOS commands.</p> Features: <ul> <li>Shows <b>progress indication</b> while creating the command reference</li> <li>Outputs an <b>command index</b> with page links</li> <li>Outputs the <b>command help text</b> for each DOS command documented by "C:>help /?"</li> </ul></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><a href="http://www.dostips.com/DosCommandIndex.bat">DosCommandIndex.bat</a></td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><a href="http://www.dostips.com/DosCommandIndex.htm">DosCommandIndex.htm</a></td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Batch.FileDate"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2009-03-30</font></font></div> <h2>File age in days - Convert the file date into Julian Days to determine the age of a file age in days</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>Date and Time functions are useful for: </p><ul> <li>Calculations with date and time values</li> <li>Determine the age of files in days</li> <li>Determine the date difference in days</li> </ul> <p></p> <p>The example in this section demonstrates how to use the <b>:ftime</b> function to determine the age in days of all files in the temp directory.</p> <p>Two variables are used </p><ul> <li>tnow - stores the current day in julian days format by calling <b>:jdate</b></li> <li>tfile - stores the file date in julian days format by calling <b>:ftime</b></li> </ul> <p></p> <p>Using <a href="http://www.dostips.com/DosCommandIndex.htm#SETLOCAL">Delayed Expansion</a> and exclamation marks around environment variables ensures that the `tfile`variable is substituted properly during each loop. Read more about this behavior in the <a href="http://www.dostips.com/DosCommandIndex.htm#SET">SET</a> command help (bottom half of the help text).</p></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchFTime.bat">BatchFTime.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br><a name="12">12.</a><br><a name="13">13.</a><br><a name="14">14.</a><br><a name="15">15.</a><br><a name="16">16.</a><br><a name="17">17.</a><br><a name="18">18.</a><br><a name="19">19.</a><br><a name="20">20.</a><br><a name="21">21.</a><br><a name="22">22.</a><br><a name="23">23.</a><br><a name="24">24.</a><br><a name="25">25.</a><br><a name="26">26.</a><br><a name="27">27.</a><br><a name="28">28.</a><br><a name="29">29.</a><br><a name="30">30.</a><br><a name="31">31.</a><br><a name="32">32.</a><br><a name="33">33.</a><br><a name="34">34.</a><br><a name="35">35.</a><br><a name="36">36.</a><br><a name="37">37.</a><br><a name="38">38.</a><br><a name="39">39.</a><br><a name="40">40.</a><br><a name="41">41.</a><br><a name="42">42.</a><br><a name="43">43.</a><br><a name="44">44.</a><br><a name="45">45.</a><br><a name="46">46.</a><br><a name="47">47.</a><br><a name="48">48.</a><br><a name="49">49.</a><br><a name="50">50.</a><br><a name="51">51.</a><br><a name="52">52.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@echo off</span><br> <span style="color=#000000">SETLOCAL ENABLEEXTENSIONS</span><br> <span style="color=#000000">SETLOCAL ENABLEDELAYEDEXPANSION</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">cd /d "%temp%"</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">call:jdate tnow "%date%"</span><br> <span style="color=#000000">for <span class="c_pvar">%%F</span> in (*.*) do (</span><br> <span style="color=#000000"> call:ftime tfile "<span class="c_pvar">%%F</span>"</span><br> <span style="color=#000000"> set /a diff=tnow-tfile</span><br> <span style="color=#000000"> echo.<span class="c_pvar">%%~nxF</span> is !diff! days old</span><br> <span style="color=#000000">)</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">ECHO.&PAUSE&GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">::-----------------------------------------------------------------------------------</span></span><br> <span style="color=#000000"><span class="c_cmmt">::-- Functions start below here</span></span><br> <span style="color=#000000"><span class="c_cmmt">::-----------------------------------------------------------------------------------</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="ftime">:ftime</a></span><span class="c_cmmt"> JD filename attr -- returns the file time in julian days</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- JD [out] - valref file time in julian days</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- attr [in,opt] - time field to be used, creation/last-access/last-write, see 'dir /?', i.e. /tc, /ta, /tw, default is /tw</span></span><br> <span style="color=#000000">:$created 20060101 :$changed 20090322 :$categories DateAndTime</span><br> <span style="color=#000000">:$source http://www.dostips.com</span><br> <span style="color=#000000">SETLOCAL</span><br> <span style="color=#000000">set file=<span class="c_pvar">%~2</span></span><br> <span style="color=#000000">set attr=<span class="c_pvar">%~3</span></span><br> <span style="color=#000000">if not defined attr (call:jdate JD "- <span class="c_pvar">%~t2</span>"</span><br> <span style="color=#000000">) ELSE (for /f <span class="c_pvar">%%a</span> in ('"dir %attr% /-c "%file%"|findstr "^^[0-9]""') do call:jdate JD "<span class="c_pvar">%%a</span>")</span><br> <span style="color=#000000">( ENDLOCAL & <span class="c_cmmt">REM RETURN VALUES</span></span><br> <span style="color=#000000"> IF "<span class="c_pvar">%~1</span>" NEQ "" (SET <span class="c_pvar">%~1</span>=%JD%) ELSE (echo.%JD%)</span><br> <span style="color=#000000">)</span><br> <span style="color=#000000">EXIT /b</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="jdate">:jdate</a></span><span class="c_cmmt"> JD DateStr -- converts a date string to julian day number with respect to regional date format</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- JD [out,opt] - julian days</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- DateStr [in,opt] - date string, e.g. "03/31/2006" or "Fri 03/31/2006" or "31.3.2006"</span></span><br> <span style="color=#000000">:$reference http://groups.google.com/group/alt.msdos.batch.nt/browse_frm/thread/a0c34d593e782e94/50ed3430b6446af8#50ed3430b6446af8</span><br> <span style="color=#000000">:$created 20060101 :$changed 20080219</span><br> <span style="color=#000000">:$source http://www.dostips.com</span><br> <span style="color=#000000">SETLOCAL</span><br> <span style="color=#000000">set DateStr=<span class="c_pvar">%~2</span>&if "<span class="c_pvar">%~2</span>"=="" set DateStr=%date%</span><br> <span style="color=#000000">for /f "skip=1 tokens=2-4 delims=(-)" <span class="c_pvar">%%a</span> in ('"echo.|date"') do (</span><br> <span style="color=#000000"> for /f "tokens=1-3 delims=/.- " <span class="c_pvar">%%A</span> in ("%DateStr:* =%") do (</span><br> <span style="color=#000000"> set <span class="c_pvar">%%a</span>=<span class="c_pvar">%%A</span>&set <span class="c_pvar">%%b</span>=<span class="c_pvar">%%B</span>&set <span class="c_pvar">%%c</span>=<span class="c_pvar">%%C</span>))</span><br> <span style="color=#000000">set /a "yy=10000%yy% <span class="c_pvar">%%1</span>0000,mm=100%mm% %% 100,dd=100%dd% %% 100"</span><br> <span style="color=#000000">set /a JD=dd-32075+1461*(yy+4800+(mm-14)/12)/4+367*(mm-2-(mm-14)/12*12)/12-3*((yy+4900+(mm-14)/12)/100)/4</span><br> <span style="color=#000000">ENDLOCAL & IF "<span class="c_pvar">%~1</span>" NEQ "" (SET <span class="c_pvar">%~1</span>=%JD%) ELSE (echo.%JD%)</span><br> <span style="color=#000000">EXIT /b</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>00000002.ini is 42 days old ActivePerlInstall.log is 39 days old BatchJDate.bat is 0 days old control.xml is 34 days old debugf.txt is 26 days old DFC5A2B2.TMP is 3 days old EML30.tmp is 2 days old EML39.tmp is 2 days old EML3D.tmp is 2 days old EXCEL.log is 20 days old fdm9E1.tmp is 39 days old gtb2C4.tmp is 62 days old tmp.cab is 62 days old - gtb2 h2rC95.tmp is 36 days old hpodvd09.log is 1 days old hpzcoi00.log is 7 days old hpzcoi01.log is 7 days old hpzcoi02.log is 7 days old hpzcoi03.log is 7 days old IMT10.xml is 73 days old IMT11.xml is 73 days old IMT12.xml is 73 days old IMT13.xml is 73 days old IMT14.xml is 73 days old IMT2B.xml is 73 days old IMTF.xml is 73 days old java_install_reg.log is 7 days old jusched.log is 1 days old LSBurnWatcher.log is 1 days old msohdinh.tmp is 62 days old patch.exe is 850 days old patchw32.dll is 850 days old r2hC94.tmp is 36 days old Press any key to continue . . . </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Batch.FtpBatchAutoLogin"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2009-12-06</font></font></div> <h2>FTP - Automatic Login - Automatically login to your FTP session with a single click</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>If you frequently find yourself calling <a href="http://www.dostips.com/DosCommandIndex.htm#FTP">FTP</a> from the command line, each time having to login and change directory and change FTP modes, until you finally get where you want be in order to do some real work then you may wish to get there with a singe click. </p><p>This little batch can connect to your FTP server and logs you in before it gives you the prompt. You can easily add more FTP commands to it, like changing directories or switching to binary mode or whatever you like to be done before taking over control on the FTP prompt. </p><p>The FTP connection information is embedded within the batch itself. The batch connects to an FTP server by executing itself in FTP context using the <a href="http://www.dostips.com/DosCommandIndex.htm#FTP">FTP</a> -s option. Once executing in FTP context it executes all FTP commands listed in the file. By omitting the final <a href="http://www.dostips.com/DosCommandIndex.htm#FTP">FTP</a> "bye" command it will stop at the FTP prompt and wait for user input. </p><p>Optionally a FTP script can be provided as input stream, that way multiple FTP scripts can share the same login information. Example: </p><p>FtpLogin.bat <script1.ftp</p></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/FtpLogin.bat">FtpLogin.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@ftp -i -s:"<span class="c_pvar">%~f0</span>"&GOTO:EOF</span><br> <span style="color=#000000">open example.com</span><br> <span style="color=#000000">username</span><br> <span style="color=#000000">password</span><br> <span style="color=#000000">pwd</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>ftp> @ftp -i -s:"%~f0"&GOTO:EOF Invalid command. ftp> open example.com Connected to example.com. 220- 220 FTP Server ready User (example.com:(none)): 331 Password required 230 User logged in ftp> pwd 257 "/" is the current directory ftp> </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name="Batch.FtpBatchGetNewFilesOnly"></a> <a name="Batch.FtpBatchDownloadOnlyNewFiles"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2010-02-05</font></font></div> <h2>FTP - Download Only New Files - Ftp script to download only files that don`t exist in local folder, i.e. to avoid overwrite</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">This batch connects twice to the FTP server. First time it retrieves a list of files on the FTP server. This list is being trimmed to contain only files that don`t already exist locally. The files in the trimmed list are then downloaded during a second connection. <p>Note: Since all files are passed into the FTP`s MGET command there might be a limit to the number of files that can be processed at once.</p></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchFtpDownloadOnlyNewFiles.bat">BatchFtpDownloadOnlyNewFiles.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br><a name="12">12.</a><br><a name="13">13.</a><br><a name="14">14.</a><br><a name="15">15.</a><br><a name="16">16.</a><br><a name="17">17.</a><br><a name="18">18.</a><br><a name="19">19.</a><br><a name="20">20.</a><br><a name="21">21.</a><br><a name="22">22.</a><br><a name="23">23.</a><br><a name="24">24.</a><br><a name="25">25.</a><br><a name="26">26.</a><br><a name="27">27.</a><br><a name="28">28.</a><br><a name="29">29.</a><br><a name="30">30.</a><br><a name="31">31.</a><br><a name="32">32.</a><br><a name="33">33.</a><br><a name="34">34.</a><br><a name="35">35.</a><br><a name="36">36.</a><br><a name="37">37.</a><br><a name="38">38.</a><br><a name="39">39.</a><br><a name="40">40.</a><br><a name="41">41.</a><br><a name="42">42.</a><br><a name="43">43.</a><br><a name="44">44.</a><br><a name="45">45.</a><br><a name="46">46.</a><br><a name="47">47.</a><br><a name="48">48.</a><br><a name="49">49.</a><br><a name="50">50.</a><br><a name="51">51.</a><br><a name="52">52.</a><br><a name="53">53.</a><br><a name="54">54.</a><br><a name="55">55.</a><br><a name="56">56.</a><br><a name="57">57.</a><br><a name="58">58.</a><br><a name="59">59.</a><br><a name="60">60.</a><br><a name="61">61.</a><br><a name="62">62.</a><br><a name="63">63.</a><br><a name="64">64.</a><br><a name="65">65.</a><br><a name="66">66.</a><br><a name="67">67.</a><br><a name="68">68.</a><br><a name="69">69.</a><br><a name="70">70.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@Echo Off</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM -- Define File Filter, i.e. files with extension .txt</span></span><br> <span style="color=#000000">Set FindStrArgs=/E /C:".txt"</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM -- Extract Ftp Script to create List of Files</span></span><br> <span style="color=#000000">Set "FtpCommand=ls"</span><br> <span style="color=#000000">Call:extractFileSection "[Ftp Script 1]" "-">"%temp%\<span class="c_pvar">%~n0</span>.ftp"</span><br> <span style="color=#000000"><span class="c_cmmt">Rem Notepad "%temp%\<span class="c_pvar">%~n0</span>.ftp"</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM -- Execute Ftp Script, collect File Names</span></span><br> <span style="color=#000000">Set "FileList="</span><br> <span style="color=#000000">For /F "Delims=" <span class="c_pvar">%%A</span> In ('"Ftp -v -i -s:"%temp%\<span class="c_pvar">%~n0</span>.ftp"|Findstr %FindStrArgs%"') Do (</span><br> <span style="color=#000000"> Call Set "FileList=<span class="c_pvar">%%F</span>ileList%% "<span class="c_pvar">%%A</span>""</span><br> <span style="color=#000000">)</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM -- Extract Ftp Script to download files that don't exist in local folder</span></span><br> <span style="color=#000000">Set "FtpCommand=mget"</span><br> <span style="color=#000000">For <span class="c_pvar">%%A</span> In (%FileList%) Do If Not Exist "<span class="c_pvar">%%~A</span>" Call Set "FtpCommand=<span class="c_pvar">%%F</span>tpCommand%% "<span class="c_pvar">%%~A</span>""</span><br> <span style="color=#000000">Call:extractFileSection "[Ftp Script 1]" "-">"%temp%\<span class="c_pvar">%~n0</span>.ftp"</span><br> <span style="color=#000000"><span class="c_cmmt">Rem Notepad "%temp%\<span class="c_pvar">%~n0</span>.ftp"</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000">For <span class="c_pvar">%%A</span> In (%FtpCommand%) Do Echo.<span class="c_pvar">%%A</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM -- Execute Ftp Script, download files</span></span><br> <span style="color=#000000">ftp -i -s:"%temp%\<span class="c_pvar">%~n0</span>.ftp"</span><br> <span style="color=#000000">Del "%temp%\<span class="c_pvar">%~n0</span>.ftp"</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="extractFileSection">:extractFileSection</a></span><span class="c_cmmt"> StartMark EndMark FileName -- extract a section of file that is defined by a start and end mark</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- [IN] StartMark - start mark, use '...:S' mark to allow variable substitution</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- [IN,OPT] EndMark - optional end mark, default is first empty line</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- [IN,OPT] FileName - optional source file, default is THIS file</span></span><br> <span style="color=#000000">:$created 20080219 :$changed 20100205 :$categories ReadFile</span><br> <span style="color=#000000">:$source http://www.dostips.com</span><br> <span style="color=#000000">SETLOCAL Disabledelayedexpansion</span><br> <span style="color=#000000">set "bmk=<span class="c_pvar">%~1</span>"</span><br> <span style="color=#000000">set "emk=<span class="c_pvar">%~2</span>"</span><br> <span style="color=#000000">set "src=<span class="c_pvar">%~3</span>"</span><br> <span style="color=#000000">set "bExtr="</span><br> <span style="color=#000000">set "bSubs="</span><br> <span style="color=#000000">if "%src%"=="" set src=<span class="c_pvar">%~f0</span>& <span class="c_cmmt">rem if no source file then assume THIS file</span></span><br> <span style="color=#000000">for /f "tokens=1,* delims=]" <span class="c_pvar">%%A</span> in ('find /n /v "" "%src%"') do (</span><br> <span style="color=#000000"> if /i "<span class="c_pvar">%%B</span>"=="%emk%" set "bExtr="&set "bSubs="</span><br> <span style="color=#000000"> if defined bExtr if defined bSubs (call echo.<span class="c_pvar">%%B</span>) ELSE (echo.<span class="c_pvar">%%B</span>)</span><br> <span style="color=#000000"> if /i "<span class="c_pvar">%%B</span>"=="%bmk%" set "bExtr=Y"</span><br> <span style="color=#000000"> if /i "<span class="c_pvar">%%B</span>"=="%bmk%:S" set "bExtr=Y"&set "bSubs=Y"</span><br> <span style="color=#000000">)</span><br> <span style="color=#000000">EXIT /b</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000">[Ftp Script 1]:S</span><br> <span style="color=#000000">!Title Connecting...</span><br> <span style="color=#000000">open example.com</span><br> <span style="color=#000000">username</span><br> <span style="color=#000000">password</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">!Title Preparing...</span><br> <span style="color=#000000">cd public_html/MyRemoteDirectory</span><br> <span style="color=#000000">lcd c:\MyLocalDirectory</span><br> <span style="color=#000000">binary</span><br> <span style="color=#000000">hash</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">!Title Processing... %FtpCommand%</span><br> <span style="color=#000000">%FtpCommand%</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">!Title Disconnecting...</span><br> <span style="color=#000000">disconnect</span><br> <span style="color=#000000">bye</span><br> </code></td> </tr></tbody></table> </td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Batch.FtpBatchUsingVariables"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-10-17</font></font></div> <h2>FTP - Resolving Environment Variables - Creating FTP script on the fly at runtime and using variables within the FTP script</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>This batch executed the FTP script embedded within the batch. All variables in the FTP script will be resolved. </p><p>The <a href="http://www.dostips.com/DosCommandIndex.htm#FOR">FOR</a> loop extracts the FTP script into a temporary file. It the <a href="http://www.dostips.com/DosCommandIndex.htm#ECHO">ECHO</a> command is being <a href="http://www.dostips.com/DosCommandIndex.htm#CALL">CALL</a>ed for each line in order to resolve the variables. </p><p>Variables can be used within the FTP script the same way as in a batch script, including any <a href="http://www.dostips.com/DtTipsStringManipulation.php">string manipulation</a> and command line arguments like %1 %2 %~n0 %* and so on. </p><p>All batch lines start with semicolon so that they will be ignored by the <a href="http://www.dostips.com/DosCommandIndex.htm#FOR">FOR</a> loop. Semicolon is the default end-of-line (EOL) character used by the <a href="http://www.dostips.com/DosCommandIndex.htm#FOR">FOR</a> command.</p></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br><a name="12">12.</a><br><a name="13">13.</a><br><a name="14">14.</a><br><a name="15">15.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">;@echo off</span><br> <span style="color=#000000">;(for /f "usebackq delims=" <span class="c_pvar">%%A</span> in ("<span class="c_pvar">%~f0</span>") do call echo.<span class="c_pvar">%%A</span>)>"%temp%\<span class="c_pvar">%~n0</span>.ftp"</span><br> <span style="color=#000000">;ftp -i -s:"%temp%\<span class="c_pvar">%~n0</span>.ftp"</span><br> <span style="color=#000000">;GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">open example.com</span><br> <span style="color=#000000">username</span><br> <span style="color=#000000">password</span><br> <span style="color=#000000">!:--- FTP commands below here ---</span><br> <span style="color=#000000">cd public_html/%COMPUTERNAME%</span><br> <span style="color=#000000">binary</span><br> <span style="color=#000000">hash on</span><br> <span style="color=#000000">%*</span><br> <span style="color=#000000">disconnect</span><br> <span style="color=#000000">bye</span><br> </code></td> </tr></tbody></table> </td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Batch.FtpBatch"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>FTP - Simple Single Batch - FTP script and batch in a single file</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>Embed FTP script into a batch script. Add this line at the beginning of the FTP script:</p> <b>@ftp -i -s:"%~f0"&GOTO:EOF</b> <p>The "FTP -s:ftpscript.txt" option executes a FTP script wheres "%~f0" resolved to the name of the running batch file. "GOTO:EOF" ends the batch script and makes sure the FTP script doesn`t run as part of the batch. <br>Good: You end up with only one file that contains the batch script and the FTP script combined. <br>Minor flaw: The batch command in the first line causes an "Invalid command." error when executed in FTP context, however the FTP execution will continue.</p> Features: <ul> <li>Single file to distribute combining batch and FTP script</li> </ul></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@ftp -i -s:"<span class="c_pvar">%~f0</span>"&GOTO:EOF</span><br> <span style="color=#000000">open example.com</span><br> <span style="color=#000000">username</span><br> <span style="color=#000000">password</span><br> <span style="color=#000000">!:--- FTP commands below here ---</span><br> <span style="color=#000000">lcd c:\MyLocalDirectory</span><br> <span style="color=#000000">cd public_html/MyRemoteDirectory</span><br> <span style="color=#000000">binary</span><br> <span style="color=#000000">mput "*.*"</span><br> <span style="color=#000000">disconnect</span><br> <span style="color=#000000">bye</span><br> </code></td> </tr></tbody></table> </td> </tr> <tr> <td class="title" valign="top">Script Output:</td> <td class="text" valign="top"><table class="dosw" border="0" cellpadding="3" cellspacing="2"> <tbody><tr><td class="title"> <img src="DOS%20Batch%20-%20Advanced%20Template_files/SysIcon.JPG" alt="DOS"> Script Ouput </td></tr> <tr><td class="text"><pre>ftp> @ftp -i -s:"%~f0"&GOTO:EOF Invalid command. ftp> open example.com User (Username:(none)): ftp> !:--- FTP commands below here --- ftp> lcd c:\MyLocalDirectory Local directory now c:\MyLocalDirectory. ftp> cd public_html/MyRemoteDirectory ftp> binary ftp> !: mput "*.*" ftp> disconnect ftp> bye </pre></td></tr></tbody></table></td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Batch.FtpBatchUploadOnlyNewFiles"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2010-02-05</font></font></div> <h2>FTP - Upload Only New Files - Ftp script to upload only files that don`t exist in remote folder, i.e. incremental upload</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">This batch connects twice to the FTP server. First time it retrieves a list of files on the FTP server. Local files that are are not in this list will then be uploaded during a second connection. <p>Note: Since all files are passed into the FTP`s MPUT command there might be a limit to the number of files that can be processed at once.</p></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchFtpUploadOnlyNewFiles.bat">BatchFtpUploadOnlyNewFiles.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br><a name="12">12.</a><br><a name="13">13.</a><br><a name="14">14.</a><br><a name="15">15.</a><br><a name="16">16.</a><br><a name="17">17.</a><br><a name="18">18.</a><br><a name="19">19.</a><br><a name="20">20.</a><br><a name="21">21.</a><br><a name="22">22.</a><br><a name="23">23.</a><br><a name="24">24.</a><br><a name="25">25.</a><br><a name="26">26.</a><br><a name="27">27.</a><br><a name="28">28.</a><br><a name="29">29.</a><br><a name="30">30.</a><br><a name="31">31.</a><br><a name="32">32.</a><br><a name="33">33.</a><br><a name="34">34.</a><br><a name="35">35.</a><br><a name="36">36.</a><br><a name="37">37.</a><br><a name="38">38.</a><br><a name="39">39.</a><br><a name="40">40.</a><br><a name="41">41.</a><br><a name="42">42.</a><br><a name="43">43.</a><br><a name="44">44.</a><br><a name="45">45.</a><br><a name="46">46.</a><br><a name="47">47.</a><br><a name="48">48.</a><br><a name="49">49.</a><br><a name="50">50.</a><br><a name="51">51.</a><br><a name="52">52.</a><br><a name="53">53.</a><br><a name="54">54.</a><br><a name="55">55.</a><br><a name="56">56.</a><br><a name="57">57.</a><br><a name="58">58.</a><br><a name="59">59.</a><br><a name="60">60.</a><br><a name="61">61.</a><br><a name="62">62.</a><br><a name="63">63.</a><br><a name="64">64.</a><br><a name="65">65.</a><br><a name="66">66.</a><br><a name="67">67.</a><br><a name="68">68.</a><br><a name="69">69.</a><br><a name="70">70.</a><br><a name="71">71.</a><br><a name="72">72.</a><br><a name="73">73.</a><br><a name="74">74.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@Echo Off</span><br> <span style="color=#000000">Setlocal Enabledelayedexpansion</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM -- Define File Filter, i.e. files with extension .txt</span></span><br> <span style="color=#000000">Set FindStrArgs=/E /C:".txt"</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM -- Extract Ftp Script to create List of Files</span></span><br> <span style="color=#000000">Set "FtpCommand=ls"</span><br> <span style="color=#000000">Call:extractFileSection "[Ftp Script 1]" "-">"%temp%\<span class="c_pvar">%~n0</span>.ftp"</span><br> <span style="color=#000000"><span class="c_cmmt">Rem Notepad "%temp%\<span class="c_pvar">%~n0</span>.ftp"</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM -- Execute Ftp Script, collect File Names</span></span><br> <span style="color=#000000">Set "FileList="</span><br> <span style="color=#000000">For /F "Delims=" <span class="c_pvar">%%A</span> In ('"Ftp -v -i -s:"%temp%\<span class="c_pvar">%~n0</span>.ftp"|Findstr %FindStrArgs%"') Do (</span><br> <span style="color=#000000"> Call Set "FileList=<span class="c_pvar">%%F</span>ileList%% "<span class="c_pvar">%%A</span>""</span><br> <span style="color=#000000">)</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM -- Extract Ftp Script to upload files that don't exist in remote folder</span></span><br> <span style="color=#000000">Set "FtpCommand=mput"</span><br> <span style="color=#000000">For <span class="c_pvar">%%A</span> In (%FileList%) Do set "Exist["<span class="c_pvar">%%~A</span>"]=Y"</span><br> <span style="color=#000000">For /F "Delims=" <span class="c_pvar">%%A</span> In ('"dir /b "%localdir%"|Findstr %FindStrArgs%"') Do (</span><br> <span style="color=#000000"> If Not defined Exist["<span class="c_pvar">%%~A</span>"] Call Set "FtpCommand=<span class="c_pvar">%%F</span>tpCommand%% "<span class="c_pvar">%%~A</span>""</span><br> <span style="color=#000000">)</span><br> <span style="color=#000000">Call:extractFileSection "[Ftp Script 1]" "-">"%temp%\<span class="c_pvar">%~n0</span>.ftp"</span><br> <span style="color=#000000"><span class="c_cmmt">rem Notepad "%temp%\<span class="c_pvar">%~n0</span>.ftp"</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000">For <span class="c_pvar">%%A</span> In (%FtpCommand%) Do Echo.<span class="c_pvar">%%A</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM -- Execute Ftp Script, download files</span></span><br> <span style="color=#000000">ftp -i -s:"%temp%\<span class="c_pvar">%~n0</span>.ftp"</span><br> <span style="color=#000000">Del "%temp%\<span class="c_pvar">%~n0</span>.ftp"</span><br> <span style="color=#000000">GOTO:EOF</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_labl"><a name="extractFileSection">:extractFileSection</a></span><span class="c_cmmt"> StartMark EndMark FileName -- extract a section of file that is defined by a start and end mark</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- [IN] StartMark - start mark, use '...:S' mark to allow variable substitution</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- [IN,OPT] EndMark - optional end mark, default is first empty line</span></span><br> <span style="color=#000000"><span class="c_cmmt">:: -- [IN,OPT] FileName - optional source file, default is THIS file</span></span><br> <span style="color=#000000">:$created 20080219 :$changed 20100205 :$categories ReadFile</span><br> <span style="color=#000000">:$source http://www.dostips.com</span><br> <span style="color=#000000">SETLOCAL Disabledelayedexpansion</span><br> <span style="color=#000000">set "bmk=<span class="c_pvar">%~1</span>"</span><br> <span style="color=#000000">set "emk=<span class="c_pvar">%~2</span>"</span><br> <span style="color=#000000">set "src=<span class="c_pvar">%~3</span>"</span><br> <span style="color=#000000">set "bExtr="</span><br> <span style="color=#000000">set "bSubs="</span><br> <span style="color=#000000">if "%src%"=="" set src=<span class="c_pvar">%~f0</span>& <span class="c_cmmt">rem if no source file then assume THIS file</span></span><br> <span style="color=#000000">for /f "tokens=1,* delims=]" <span class="c_pvar">%%A</span> in ('find /n /v "" "%src%"') do (</span><br> <span style="color=#000000"> if /i "<span class="c_pvar">%%B</span>"=="%emk%" set "bExtr="&set "bSubs="</span><br> <span style="color=#000000"> if defined bExtr if defined bSubs (call echo.<span class="c_pvar">%%B</span>) ELSE (echo.<span class="c_pvar">%%B</span>)</span><br> <span style="color=#000000"> if /i "<span class="c_pvar">%%B</span>"=="%bmk%" set "bExtr=Y"</span><br> <span style="color=#000000"> if /i "<span class="c_pvar">%%B</span>"=="%bmk%:S" set "bExtr=Y"&set "bSubs=Y"</span><br> <span style="color=#000000">)</span><br> <span style="color=#000000">EXIT /b</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000">[Ftp Script 1]:S</span><br> <span style="color=#000000">!Title Connecting...</span><br> <span style="color=#000000">open example.com</span><br> <span style="color=#000000">username</span><br> <span style="color=#000000">password</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">!Title Preparing...</span><br> <span style="color=#000000">cd public_html/MyRemoteDirectory</span><br> <span style="color=#000000">lcd c:\MyLocalDirectory</span><br> <span style="color=#000000">binary</span><br> <span style="color=#000000">hash</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">!Title Processing... %FtpCommand%</span><br> <span style="color=#000000">%FtpCommand%</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">!Title Disconnecting...</span><br> <span style="color=#000000">disconnect</span><br> <span style="color=#000000">bye</span><br> </code></td> </tr></tbody></table> </td> </tr> </tbody></table> <hr> <a name=""></a> <a name="Batch.FtpBatchLoginSharing"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2009-12-06</font></font></div> <h2>FTP Scripts Sharing Login Info - Manage the FTP login separately from your FTP scripts</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>If you have multiple FTP scripts that all use the same login information to your FTP site then you may wish to manage the login information separately from your FTP scripts in a single place. That way if the username, password or hostname for the FTP connection changes you only need to edit a single place instead of having to edit all FTP scripts one by one. </p><p>This automatic login script (also described in detail earlier) can be used to execute different FTP scripts that share the same login information stored within the batch file. </p><p>Example: <b>FtpLogin.bat script1.ftp</b> </p><p><b>Note:</b> The FTP scripts passed into the batch must have the login sequence removed. </p><p><b>Note:</b> The FTP script executes even if the connection sequence fails potentially causing `Not connected` and other errors. This is no different from regularly executing <a href="http://www.dostips.com/DosCommandIndex.htm#FTP">FTP</a> with -s option. </p></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/FtpLoginSharing.bat">FtpLoginSharing.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@type %1|ftp -i -s:"<span class="c_pvar">%~f0</span>"&GOTO:EOF</span><br> <span style="color=#000000">open example.com</span><br> <span style="color=#000000">username</span><br> <span style="color=#000000">password</span><br> </code></td> </tr></tbody></table> </td> </tr> </tbody></table> <hr> <a name="_Toc134470226"></a> <a name="Interfacing.Sql"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>OSQL.EXE - Run SQL script from DOS Batch - SQL script and dos batch script in one file, the One-File Solution</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>Embedding SQL script within a batch script is just as easy. The following batch script executes itself in SQL context. The trick is the GOTO command in the first line of the script. When executing GOTO START in batch context than the command processor will jump to the label ":START" and execute the batch script. The batch script will then run the OSQL.EXE using the batch file itself as SQL file argument to be executed. When subsequently executing the GOTO START line in SQL context, the query language processor will jump to the label "START:" and execute the SQL queries. In fact the file can be opened and executed in Query Analyzer as is, since the batch script in the file looks like a comment to the query language processor.</p></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/Batch4SQL.bat">Batch4SQL.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br><a name="12">12.</a><br><a name="13">13.</a><br><a name="14">14.</a><br><a name="15">15.</a><br><a name="16">16.</a><br><a name="17">17.</a><br><a name="18">18.</a><br><a name="19">19.</a><br><a name="20">20.</a><br><a name="21">21.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">GOTO START</span><br> <span style="color=#000000">-- DOS jumps to the ':START' label</span><br> <span style="color=#000000">-- SQL jumps to the 'START:' label</span><br> <span style="color=#000000">-- Source http://www.dostips.com</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">/* Begin of SQL comment, this makes the BATCH script invisible for SQL</span><br> <span style="color=#000000"><span class="c_cmmt">:: BATCH starts below here</span></span><br> <span style="color=#000000"><span class="c_labl"><a name="START">:START</a></span><span class="c_cmmt"></span></span><br> <span style="color=#000000">@echo off</span><br> <span style="color=#000000">CLS</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">OSQL.EXE -n -E -w 65536 -d NORTHWIND -i "<span class="c_pvar">%~f0</span>"</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">PAUSE&GOTO:EOF</span><br> <span style="color=#000000">*/</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">-- SQL starts below here</span><br> <span style="color=#000000">START:</span><br> <span style="color=#000000">GO</span><br> <span style="color=#000000">SELECT * FROM AUTHOR</span><br> <span style="color=#000000">GO</span><br> </code></td> </tr></tbody></table> </td> </tr> </tbody></table> <hr> <a name="_Toc134470227"></a> <a name="Interfacing.Sql2"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>OSQL.EXE - Run SQL script from DOS Batch, passing parameters - Run SQL scripts with parameters passed in from the batch script</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>Now we can embed SQL queries into a batch file. But how can we pass arguments from the batch script into SQL? This can be done using a temporary table. Temporary tables live as long as the connection to the SQL Server. But how can we fill a temporary table with runtime data and execute the embedded SQL script without creating two separate SQL Server connections by calling OSQL.EXE twice? The trick is that OSQL allows to use the -i and -q option at the same time whereas: </p><ul> <li>-q specifies a query string to be executed</li> <li>-i specifies a filename with SQL syntax to be executed</li> </ul> Both the query string and the SQL file will be executed using the same Server connection. Some testing shows that the query string -q will always be executed before the -I SQL file, which allows us to use a query string to set up a temporary table. <p></p></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/Batch4SQL2.bat">Batch4SQL2.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br><a name="12">12.</a><br><a name="13">13.</a><br><a name="14">14.</a><br><a name="15">15.</a><br><a name="16">16.</a><br><a name="17">17.</a><br><a name="18">18.</a><br><a name="19">19.</a><br><a name="20">20.</a><br><a name="21">21.</a><br><a name="22">22.</a><br><a name="23">23.</a><br><a name="24">24.</a><br><a name="25">25.</a><br><a name="26">26.</a><br><a name="27">27.</a><br><a name="28">28.</a><br><a name="29">29.</a><br><a name="30">30.</a><br><a name="31">31.</a><br><a name="32">32.</a><br><a name="33">33.</a><br><a name="34">34.</a><br><a name="35">35.</a><br><a name="36">36.</a><br><a name="37">37.</a><br><a name="38">38.</a><br><a name="39">39.</a><br><a name="40">40.</a><br><a name="41">41.</a><br><a name="42">42.</a><br><a name="43">43.</a><br><a name="44">44.</a><br><a name="45">45.</a><br><a name="46">46.</a><br><a name="47">47.</a><br><a name="48">48.</a><br><a name="49">49.</a><br><a name="50">50.</a><br><a name="51">51.</a><br><a name="52">52.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">GOTO START</span><br> <span style="color=#000000">-- DOS jumps to the ':START' label</span><br> <span style="color=#000000">-- SQL jumps to the 'START:' label</span><br> <span style="color=#000000">-- Source http://www.dostips.com</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">/* Begin of SQL comment, this makes the BATCH script invisible for SQL</span><br> <span style="color=#000000"><span class="c_cmmt">:: BATCH starts below here</span></span><br> <span style="color=#000000"><span class="c_labl"><a name="START">:START</a></span><span class="c_cmmt"></span></span><br> <span style="color=#000000">@echo off</span><br> <span style="color=#000000">CLS</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">set /p AuthorName=Author Name:</span><br> <span style="color=#000000">set /p AuthorCity=Author City:</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">rem.-------------------------------------------------------------------------</span></span><br> <span style="color=#000000"><span class="c_cmmt">rem.Execute THIS file in SQL context transmitting arguments per temp table</span></span><br> <span style="color=#000000">set Args=</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">rem.--BEGIN ARGS SECTION ------------------</span></span><br> <span style="color=#000000">set Args=%Args% INSERT #ArgsTable VALUES ('AuthorName','%AuthorName%')</span><br> <span style="color=#000000">set Args=%Args% INSERT #ArgsTable VALUES ('AuthorCity','%AuthorCity%')</span><br> <span style="color=#000000"><span class="c_cmmt">rem.--END ARGS SECTION ------------------</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000">set Args= -q "SET NOCOUNT ON CREATE TABLE #ArgsTable(Arg char(16) PRIMARY KEY, Val char(32)) %Args%"</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">OSQL.EXE -n -E -w 65536 -d NORTHWIND %Args% -i "<span class="c_pvar">%~f0</span>"</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">PAUSE&GOTO:EOF</span><br> <span style="color=#000000">*/</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">-- SQL starts below here</span><br> <span style="color=#000000">START:</span><br> <span style="color=#000000">GO</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">DECLARE @AuthorName varchar(128)</span><br> <span style="color=#000000">DECLARE @AuthorCity varchar(128)</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">--Set defaults for values as needed</span><br> <span style="color=#000000">SET @AuthorName = ''</span><br> <span style="color=#000000">SET @AuthorCity = ''</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">--Copy data from temporary table into variables</span><br> <span style="color=#000000">IF EXISTS (SELECT name, type FROM tempdb..sysobjects WHERE name like '#ArgsTable_%' AND type = 'U')</span><br> <span style="color=#000000">BEGIN</span><br> <span style="color=#000000"> SELECT @AuthorName=Val FROM #ArgsTable WHERE Arg='AuthorName'</span><br> <span style="color=#000000"> SELECT @AuthorCity=Val FROM #ArgsTable WHERE Arg='AuthorCity'</span><br> <span style="color=#000000">END</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">print @AuthorName</span><br> <span style="color=#000000">print @AuthorCity</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">GO</span><br> </code></td> </tr></tbody></table> </td> </tr> </tbody></table> <hr> <a name="_Toc134470224"></a> <a name="Interfacing.Perl"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>Perl - Perl Script within a DOS Batch - Perl script and batch in a single file</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>It`s nice not to have to type <b>"perl -s Batch4Parl.pl"</b> into the command line and rather being able to just double click a Perl script in Explorer. The trick of renaming the Perl .pl to a batch .bat file and wrapping a batch script around the Perl script is well known under Perl monks. However the solution I have seen so far needed batch code before and after the Perl script where as the solution presented below only needs some lines of DOS at the top. The added DOS script is generic and works independent from the name of the file.</p> <p>When running the batch the DOS command interpreter will read the first lines and execute the file itself in Perl context.</p></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/Batch4Perl.bat">Batch4Perl.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@<span class="c_cmmt">rem = 'source http://www.dostips.com</span></span><br> <span style="color=#000000">@CD/d"<span class="c_pvar">%~dp0</span>"&perl -s "<span class="c_pvar">%~nx0</span>" %*&Exit/b&:';</span><br> <span style="color=#000000"></span><br> <span style="color=#000000">#perl script starts below here</span><br> <span style="color=#000000">print 'Hi there! DOS rocks!\n'</span><br> </code></td> </tr></tbody></table> </td> </tr> </tbody></table> <hr> <a name="_Toc134470225"></a> <a name="Interfacing.Perl2"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>Perl Script within a DOS Batch with delayed exit - Perl script and batch in a single file</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top"><p>This example works just as the previews one but will wait 4 seconds before the application finally closes. This is just enough time to inspect the screen output before the window vanishes. The delay can probably be done much easier in Perl, but somebody just starting on Perl might find this still useful.</p></td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/Batch4Perl2.bat">Batch4Perl2.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@<span class="c_cmmt">rem = 'Perl, ccperl will read this as an array of assignment & skip this block</span></span><br> <span style="color=#000000">@CD /d "<span class="c_pvar">%~dp0</span>"</span><br> <span style="color=#000000">@perl -s "<span class="c_pvar">%~nx0</span>" %*</span><br> <span style="color=#000000">@FOR /L <span class="c_pvar">%%c</span> in (4,-1,1) do @(TITLE <span class="c_pvar">%~nx0</span> - <span class="c_pvar">%%c</span>s to close & ping -n 2 -w 1000 127.0.0.1 >NUL)</span><br> <span style="color=#000000">@TITLE Press any key to close the window&ECHO.&GOTO:EOF</span><br> <span style="color=#000000">@<span class="c_cmmt">rem ';</span></span><br> <span style="color=#000000"></span><br> <span style="color=#000000">#perl script starts below here</span><br> <span style="color=#000000">print 'Hi there! DOS rocks!\n'</span><br> </code></td> </tr></tbody></table> </td> </tr> </tbody></table> <hr> <a name="_Toc145951132"></a> <a name="Batch.SimpleTemplate"></a> <div style="float: right;"><font color="darkblue"><a href="#">TOP</a><br><font size="1">2008-01-01</font></font></div> <h2>Simple Batch Template - Template with simple init and exit</h2> <table class="posts"> <tbody><tr> <td class="title" valign="top">Description:</td> <td class="text" valign="top">The function template can be used as starting point for a new batch.</td> </tr> <tr> <td class="title" valign="top">Script:</td> <td class="text" valign="top"><span style="float:right;">Download: <a href="http://www.dostips.com/BatchSimple.bat">BatchSimple.bat</a> </span> <table class="btchscr"><tbody><tr> <td class="numbrs" align="right" nowrap="nowrap"><code><a name="1">1.</a><br><a name="2">2.</a><br><a name="3">3.</a><br><a name="4">4.</a><br><a name="5">5.</a><br><a name="6">6.</a><br><a name="7">7.</a><br><a name="8">8.</a><br><a name="9">9.</a><br><a name="10">10.</a><br><a name="11">11.</a><br><a name="12">12.</a><br><a name="13">13.</a><br></code></td> <td class="code" nowrap="nowrap"><code><span style="color=#000000">@ECHO OFF</span><br> <span style="color=#000000"><span class="c_cmmt">REM.-- Prepare the Command Processor</span></span><br> <span style="color=#000000">SETLOCAL ENABLEEXTENSIONS</span><br> <span style="color=#000000">SETLOCAL ENABLEDELAYEDEXPANSION</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM.-- your code goes here</span></span><br> <span style="color=#000000">echo.Hello World</span><br> <span style="color=#000000"></span><br> <span style="color=#000000"></span><br> <span style="color=#000000"><span class="c_cmmt">REM.-- End of application</span></span><br> <span style="color=#000000">ECHO.&ECHO.Press any key to end the application.</span><br> <span style="color=#000000">PAUSE>NUL&GOTO:EOF</span><br> </code></td> </tr></tbody></table> </td> </tr> </tbody></table> <br><br> <a href="http://www.amazon.com/gp/product/0735622620?ie=UTF8&tag=dos01-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0735622620"><img src="DOS%20Batch%20-%20Advanced%20Template_files/51JXrVTAGnL.jpg" border="0"></a><img src="DOS%20Batch%20-%20Advanced%20Template_files/ir_002.gif" alt="" style="border: medium none ! important; margin: 0px ! important;" height="1" border="0" width="1"> <a href="http://www.amazon.com/gp/product/0735625956/ref=as_li_tf_il?ie=UTF8&tag=dos01-20&linkCode=as2&camp=217145&creative=399353&creativeASIN=0735625956"><img src="DOS%20Batch%20-%20Advanced%20Template_files/q.jpg" border="0"></a><img src="DOS%20Batch%20-%20Advanced%20Template_files/ir.gif" alt="" style="border: medium none ! important; margin: 0px ! important;" height="1" border="0" width="1"> <script type="text/javascript"><!-- google_ad_client = "pub-4331089886589220"; /* 468x60, created 12/30/07 */ google_ad_slot = "8403807900"; google_ad_width = 468; google_ad_height = 60; //--> </script> <script type="text/javascript" src="DOS%20Batch%20-%20Advanced%20Template_files/show_ads.js"> </script><ins style="display:inline-table;border:none;height:60px;margin:0;padding:0;position:relative;visibility:visible;width:468px"><ins id="aswift_0_anchor" style="display:block;border:none;height:60px;margin:0;padding:0;position:relative;visibility:visible;width:468px"><iframe allowtransparency="true" hspace="0" marginwidth="0" marginheight="0" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&&s.handlers,h=H&&H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&&d&&(!d.body||!d.body.firstChild)){if(h.call){i+='.call';setTimeout(h,0)}else if(h.match){i+='.nav';w.location.replace(h)}s.log&&s.log.push(i)}" vspace="0" id="aswift_0" name="aswift_0" style="left: 0pt; position: absolute; top: 0pt;" frameborder="0" height="60" scrolling="no" width="468"></iframe></ins></ins> <div class="bot"> <script type="text/javascript"> /*********************************************** * IFrame SSI script II- Copyright Dynamic Drive DHTML code library (http://www.dynamicdrive.com) * Visit DynamicDrive.com for hundreds of original DHTML scripts * This notice must stay intact for legal use ***********************************************/ //Input the IDs of the IFRAMES you wish to dynamically resize to match its content height: //Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none: var iframeids=["myframe"] //Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended): var iframehide="yes" var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1] var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers function resizeCaller() { var dyniframe=new Array() for (i=0; i<iframeids.length; i++){ if (document.getElementById) resizeIframe(iframeids[i]) //reveal iframe for lower end browsers? (see var above): if ((document.all || document.getElementById) && iframehide=="no"){ var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i]) tempobj.style.display="block" } } } function resizeIframe(frameid){ var currentfr=document.getElementById(frameid) if (currentfr && !window.opera){ currentfr.style.display="block" if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax currentfr.height = currentfr.Document.body.scrollHeight; if (currentfr.addEventListener) currentfr.addEventListener("load", readjustIframe, false) else if (currentfr.attachEvent){ currentfr.detachEvent("onload", readjustIframe) // Bug fix line currentfr.attachEvent("onload", readjustIframe) } } } function readjustIframe(loadevt) { var crossevt=(window.event)? event : loadevt var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement if (iframeroot) resizeIframe(iframeroot.id); } function loadintoIframe(iframeid, url){ if (document.getElementById) document.getElementById(iframeid).src=url } if (window.addEventListener) window.addEventListener("load", resizeCaller, false) else if (window.attachEvent) window.attachEvent("onload", resizeCaller) else window.onload=resizeCaller </script> <center> <br> <br> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script><script src="DOS%20Batch%20-%20Advanced%20Template_files/ga.js" type="text/javascript"></script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-280191-1"); pageTracker._initData(); pageTracker._trackPageview(); </script> <br> </center> <iframe id="myframe" src="DOS%20Batch%20-%20Advanced%20Template_files/viewforum.htm" marginwidth="0" marginheight="0" style="overflow: visible; display: block;" frameborder="0" height="2824" width="100%"></iframe></div> </body></html>