rad89.com

Picked up by ... thanks guys!

Fast Command Line Database (simple DOS Batch version - f.bat)

May 25, 2009 by Scott Brodsky
submit to reddit

FAST is a Windows command-line utility to retrieve passwords, phone numbers, notes, etc. from your computer or USB thumb drive.

This utility has saved me an incredible amount of time. I use it to store phone numbers, addresses, command syntax for various languages, wants, to-do lists, etc.

Say I want to find my local pizza restaurant's phone number, which is already in my database:

c:\>f pizza

Result:

---------- E:\TXT\NOTES.TXT
papa ginos pizza londonderry          434-8555

Say I want to add a phone # to my notes database:

c:\>f -add "kentucky fried chicken kfc londonderry 603-423-6840"
ok

Now let's verify the record was added. We will search for 'kfc':

c:\>f kfc

---------- E:\TXT\NOTES.TXT
"kentucky fried chicken kfc londonderry 603-423-6840"

Here is what the code for [f.bat] looks like:

@echo off
set file=notes.txt
if (%1)==(-add) goto add 
if (%1)==(-?) goto usage
if (%1)==() goto usage
if not (%1)==() goto find
goto end

:ADD
set out=%*
echo %out:~5% >> %file%
echo ok
goto end

:FIND
find /i "%1" %file%
goto end

:USAGE
echo USAGE: f keyword
echo        f -add "some string of data"
goto end

:END

You will want to change [e:\txt\notes.txt] to contain the path and filename of your personal notes file. I kept mine on a USB flash drive.

All notes or "records" are delimited by carriage return linefeeds.

There are no errorlevel checks here because the find and redirect commands have extensive error checks built-in.

You will need to place the location of your [f.bat] script in your PATH environment variable. i.e. if you are storing your f.bat script at c:\utils\f.bat, then click Start...right click My Computer...choose Properties...Advanced Tab...Environment Variables button...Bottom Window...select PATH and EDIT...append ;c:\utils to Variable Value...click OK...OK...OK. Changes will take effect when you open a new command line window.

This program worked great for a year, then I got tired of having to get up and retrieve my USB thumb drive every time I needed to retrieve a note. I wrote a newer version which uses a PERL web hosted script and notes file, and a client C# command line program to retrieve the data. The advantage being that I will be able to access my notes from my work and home computers via the client access to the web hosted notes file. Disadvantages are that the URL must be large so that it cannot be easily hacked and you must not store sensitive password information. I will be posting that code soon.

Fast Command Line Database for Unix

May 28, 2009 by Scott Brodsky

hdiwan over at blog.ProlificProgrammer.com has created a Unix version!

Use FAST command line database with Dropbox

May 30, 2009 by Scott Brodsky

Mark Joyal suggested using dropbox which stores your data remotely over the net. I have tested and it works perfectly. The only drawbacks with using Dropbox are 1) Dropbox requires you to download and install their software and create an online account, 2) You must install Dropbox on each machine you use, and 3) You may not have administrative rights on your machine at work to install software.

Cleaner output results

May 30, 2009 by Scott Brodsky

Reader 'CutTheRedWire' sent me the following tip to clean up the output of the find command:

			type e:\txt\notes.txt|find /i "%1"
			

More Enhancements

Jun 27, 2009 by Scott Brodsky

Reader 'Rocky' sent along an even cleaner version:

@echo off
set file=notes.txt 
if (%1)==(-add) goto add
if (%1)==(-?) goto usage
if (%1)==() goto usage
if not (%1)==() goto find 
goto end 

:ADD
set out=%*
echo %out:~5% >> %file% 
echo ok 
goto end 

:FIND 
type %file%|find /i "%1" 
goto end 

:USAGE 
echo USAGE: f keyword 
echo f -add "some string of data" 
goto end 

:END 

The tricky part of 'echo %out:~5 >> %file%' does the following: "The first line assigns all the command parameters to a variable called out. The second line echos the out variable from character 5 onward. This gets rid of the -add_. (Which would be %1). "