<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: batch code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Wed, 23 Jul 2008 20:01:45 GMT</pubDate>
    <description>DZone Snippets: batch code</description>
    <item>
      <title>Batch loop for wave to mp3 (using lame)</title>
      <link>http://snippets.dzone.com/posts/show/5464</link>
      <description>It keeps the input files and sorts both mp3 and wave files nicely in two separate directories.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;@echo off&lt;br /&gt;if NOT EXIST MP3 md MP3&lt;br /&gt;if NOT EXIST WAV md WAV&lt;br /&gt;&lt;br /&gt;for %%f in (*.wav) do (&lt;br /&gt;	cls&lt;br /&gt;	lame -b 96 -V 5 -B 128 -m j --vbr-new -q 5 "%%f" "MP3\%%f.mp3"&lt;br /&gt;	move "%%f" WAV&lt;br /&gt;)&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 05 May 2008 19:57:11 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5464</guid>
      <author>jakob ()</author>
    </item>
    <item>
      <title>Batch re-size a collection of images from the command line</title>
      <link>http://snippets.dzone.com/posts/show/5298</link>
      <description>&lt;code&gt;&lt;br /&gt;for img in $(ls *.png); do convert $img -resize 75% smaller-$img; done;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 01 Apr 2008 09:33:24 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5298</guid>
      <author>27stars (27stars)</author>
    </item>
    <item>
      <title>find line in text file, add to another text file</title>
      <link>http://snippets.dzone.com/posts/show/4262</link>
      <description>// Batch - search .txt / .csv / etc using argument, return matches to .txt / .csv / etc file&lt;br /&gt;// skips the ---------- foo.csv returned by find alone&lt;br /&gt;&lt;code&gt;&lt;br /&gt;find /i "%1" foo.csv | find /i "%1" &gt;&gt; bar.txt&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 05 Jul 2007 12:03:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4262</guid>
      <author>thefamousnomo (Robin)</author>
    </item>
    <item>
      <title>Batch code to make win folder hidden and password protected</title>
      <link>http://snippets.dzone.com/posts/show/4244</link>
      <description>Open any text editor and copy the the contents of this code to a text file and save it with any name having .bat extension.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cls&lt;br /&gt;@ECHO OFF&lt;br /&gt;echo 			// Check1 (In Main Function)&lt;br /&gt;title Folder LockFolder&lt;br /&gt;if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLockFolder&lt;br /&gt;if NOT EXIST LockFolder goto MDLockFolder&lt;br /&gt;:AuthConfirm&lt;br /&gt;echo Are you sure u want to Lock Folder  (Y/N)&lt;br /&gt;set/p "cho=&gt;"&lt;br /&gt;if %cho%==Y goto LockFolder&lt;br /&gt;if %cho%==y goto LockFolder&lt;br /&gt;if %cho%==n goto END&lt;br /&gt;if %cho%==N goto END&lt;br /&gt;echo Invalid choice.&lt;br /&gt;goto AuthConfirm&lt;br /&gt;:LockFolder&lt;br /&gt;ren LockFolder "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"&lt;br /&gt;attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"&lt;br /&gt;echo Folder LockFolder Locked!&lt;br /&gt;goto End&lt;br /&gt;:UNLockFolder&lt;br /&gt;echo Enter password to Unlock Folder&lt;br /&gt;set/p "pass=&gt;"&lt;br /&gt;if NOT %pass%==TYPE YOUR PASSWORD HERE goto FailUnlock&lt;br /&gt;attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"&lt;br /&gt;ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" LockFolder&lt;br /&gt;echo Folder UnLocked successfully!&lt;br /&gt;goto End&lt;br /&gt;:FailUnlock&lt;br /&gt;echo Invalid password!&lt;br /&gt;echo Try again?  (Y/N)&lt;br /&gt;set/p "choice=&gt;"&lt;br /&gt;if %choice%==Y goto UNLockFolder&lt;br /&gt;if %choice%==y goto UNLockFolder&lt;br /&gt;if %choice%==N goto END&lt;br /&gt;if %choice%==n goto END&lt;br /&gt;:MDLockFolder&lt;br /&gt;echo 			// Check2 (In MD Dir Function)&lt;br /&gt;md LockFolder&lt;br /&gt;echo Folder LockFolder created successfully!&lt;br /&gt;goto End&lt;br /&gt;:End&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 04 Jul 2007 09:02:59 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4244</guid>
      <author>scidmark (Pardeep Bukarwal)</author>
    </item>
    <item>
      <title>Opera Syncing using Svn</title>
      <link>http://snippets.dzone.com/posts/show/4219</link>
      <description>This batch file allows to run opera after checking out your web-based opera profile. When you terminate your opera session, the batch will commit the changes you made to your profile during the opera session.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt; REM OperaSync.bat&lt;br /&gt; @echo off&lt;br /&gt; &lt;br /&gt; set PRG=Opera&lt;br /&gt; set TARGET=%APPDATA%/%PRG%/%PRG%/profile&lt;br /&gt; set EXEC=%PROGS%/%PRG%/%PRG%.exe&lt;br /&gt; set REPO=https://********.googlecode.com/svn/trunk/%PROG%Sync&lt;br /&gt; set USER=*************&lt;br /&gt; &lt;br /&gt; echo Checking out from %REPO% ...&lt;br /&gt; svn checkout %REPO% "%TARGET%" --username %USER%&lt;br /&gt; echo %PROG% running ...&lt;br /&gt; %EXEC%&lt;br /&gt; echo Commiting to %REPO% ...&lt;br /&gt; svn commit -m --force-log "%TARGET%"&lt;br /&gt; echo Done.&lt;br /&gt; &lt;br /&gt; @echo on&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Here's the list of files that I update from a svn repo for my Opera profile&lt;br /&gt;&lt;code&gt;&lt;br /&gt;contacts.adr&lt;br /&gt;files.txt&lt;br /&gt;jscripts/&lt;br /&gt;jscripts/deliciousmp3.js&lt;br /&gt;notes.adr&lt;br /&gt;opcacrt6.dat&lt;br /&gt;opcert6.dat&lt;br /&gt;opera6.adr&lt;br /&gt;search.ini&lt;br /&gt;sessions/&lt;br /&gt;sessions/autosave.win&lt;br /&gt;sessions/autosave.win.bak&lt;br /&gt;speeddial.ini&lt;br /&gt;&lt;/code&gt;&lt;br /&gt; </description>
      <pubDate>Thu, 28 Jun 2007 18:47:19 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4219</guid>
      <author>griflet (guillaume riflet)</author>
    </item>
    <item>
      <title>batch set day / date / time variables</title>
      <link>http://snippets.dzone.com/posts/show/4142</link>
      <description>// set day / day / time variables in batch&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cd %temp%&lt;br /&gt;echo.|date&gt;datevar.bat&lt;br /&gt;echo.|time&gt;timevar.bat&lt;br /&gt;echo set DATEvar=%%4&gt;current.bat&lt;br /&gt;call datevar&lt;br /&gt;echo set DAYvar=%%3&gt;current.bat&lt;br /&gt;call datevar&lt;br /&gt;echo set TIMEvar=%%3&gt;current.bat&lt;br /&gt;call timevar&lt;br /&gt;echo %DAYvar%&lt;br /&gt;echo %DATEvar%&lt;br /&gt;echo %TIMEvar%&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 14 Jun 2007 12:58:37 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4142</guid>
      <author>thefamousnomo (Robin)</author>
    </item>
    <item>
      <title>basic batch drive presence check</title>
      <link>http://snippets.dzone.com/posts/show/4141</link>
      <description>// check if removable drives are present. useful with batch backups and letter-jumping flash drives.&lt;br /&gt;// floppies (a:, b:) can cause screen flash asking for floppy to be inserted.&lt;br /&gt;//&lt;br /&gt;// two batch files required - 1. foo.bat&lt;br /&gt;&lt;code&gt;&lt;br /&gt;@echo off&lt;br /&gt;echo simple drive check &gt; %temp%\tmp.txt&lt;br /&gt;echo. &gt;&gt; %temp%\tmp.txt&lt;br /&gt;for %%a in (c:, d:, e:, f:, g:) do call bar.bat %%a&lt;br /&gt;cls&lt;br /&gt;type %temp%\tmp.txt&lt;br /&gt;echo.&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;// 2. bar.bat&lt;br /&gt;&lt;code&gt;&lt;br /&gt;%comspec% /f /c vol %1 | find /c "Vol" | choice /c:210&lt;br /&gt;if not errorlevel 2 if errorlevel 1 echo %1 present &gt;&gt; %temp%\tmp.txt&lt;br /&gt;if not errorlevel 3 if errorlevel 2 echo %1 not present &gt;&gt; %temp%\tmp.txt&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;// screen output can be suppressed by wrapping&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ctty nul&lt;br /&gt;for %%a in (c:, d:, e:, f:, g:) do call bar.bat %%a&lt;br /&gt;ctty con&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;// in foo.bat</description>
      <pubDate>Thu, 14 Jun 2007 08:22:58 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4141</guid>
      <author>thefamousnomo (Robin)</author>
    </item>
    <item>
      <title>basic batch conditional evaluation</title>
      <link>http://snippets.dzone.com/posts/show/4138</link>
      <description>// check if argument has been passed to batch file&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;if not [%1]==[] echo %1&lt;br /&gt;if not [%1]'==' echo %1&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 13 Jun 2007 15:42:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4138</guid>
      <author>thefamousnomo (Robin)</author>
    </item>
    <item>
      <title>MySql Backups Under Windows</title>
      <link>http://snippets.dzone.com/posts/show/1693</link>
      <description>This batch script will backup any MySql database on the local machine, including all routines (stored procedures and functions), to a file named after the database followed by the date (YYYY-MM-DD) and time (HHMMSSSS). The first argument is the database name, second is the username to run the backup as and third is the password.&lt;br /&gt;&lt;br /&gt;This script requires your date and time formats to be the windows default formats. Changing them can break this script. The script pauses at the end to cause a cmd window to remain open for long enough for the user to read the output.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;@echo off&lt;br /&gt;echo Starting Backup of Database: %1&lt;br /&gt;&lt;br /&gt;For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set dt=%%c-%%a-%%b)&lt;br /&gt;For /f "tokens=1-4 delims=:." %%a in ('echo %time%') do (set tm=%%a%%b%%c%%d)&lt;br /&gt;set bkupfilename=%1 %dt% %tm%.bak&lt;br /&gt;echo Backing up to file: %bkupfilename%&lt;br /&gt;&lt;br /&gt;mysqldump %1 --routines -u %2 -p%3 &gt; "%bkupfilename%"&lt;br /&gt;&lt;br /&gt;echo Backup Complete!&lt;br /&gt;pause&lt;br /&gt;echo on&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;-- &lt;br /&gt;Version 0.1.0 - 2006-03-13&lt;br /&gt;STEM: The STEM Cells of PHP&lt;br /&gt;This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License&lt;br /&gt;http://creativecommons.org/licenses/by-sa/2.5/</description>
      <pubDate>Mon, 13 Mar 2006 17:29:02 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1693</guid>
      <author>Charlie (Stephen Martindale)</author>
    </item>
    <item>
      <title>One-click connect from cygwin to full-screen Linux (X stuff required)</title>
      <link>http://snippets.dzone.com/posts/show/1298</link>
      <description>Optional: execute the following once (see http://hacks.oreilly.com/pub/h/66 for &lt;br /&gt;details), to avoid typing in the password.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;set LINUX_HOST=mylinuxhost&lt;br /&gt;ssh-keygen -t rsa&lt;br /&gt;ssh %USERNAME%@%LINUX_HOST% "mkdir .ssh; chmod 0700 .ssh"&lt;br /&gt;bash -c 'scp ~/.ssh/id_rsa.pub %LINUX_HOST%:.ssh/authorized_keys2'&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Now, if you save the following as a BATCH file, you can just click it &lt;br /&gt;to connect to fullscreen Linux: &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;set LINUX_HOST=mylinuxhost&lt;br /&gt;start /min xinit &lt;br /&gt;xhost +%LINUX_HOST%&lt;br /&gt;ssh %LINUX_HOST% "declare -x DISPLAY=%COMPUTERNAME%:0; echo $DISPLAY;gnome-session"'&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;NOTES: &lt;br /&gt;1. &lt;br /&gt;Sometimes xhost + does not execute in time. O well. Just close&lt;br /&gt;all windows that got opened and try again.&lt;br /&gt;&lt;br /&gt;2.&lt;br /&gt;If you didn't do the step one (ssh keys), you will be prompted &lt;br /&gt;to enter the linux password; this increases the chances of the above&lt;br /&gt;error.&lt;br /&gt;&lt;br /&gt;3.&lt;br /&gt;The single terminal window appearing in the Linux desktop is in fact &lt;br /&gt;a window from your PC. &lt;br /&gt;&lt;br /&gt;</description>
      <pubDate>Wed, 25 Jan 2006 22:13:49 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1298</guid>
      <author>debedb (http://www.hrum.org)</author>
    </item>
  </channel>
</rss>
