Navigation

Search

Categories

On this page

Setting up a filename for with the current time in a batch script
go somewhere new
Placate vs Educate

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 120
This Year: 1
This Month: 0
This Week: 0
Comments: 40

Sign In
Pick a theme:

# Monday, December 11, 2006
Monday, December 11, 2006 1:01:53 PM (Mountain Standard Time, UTC-07:00) ( Code )

I've found myself using this pattern alot lately. I figured I'd post it for posterity.


@ECHO OFF

SET NOWD=%DATE%
SET mm=%NOWD:~4,2%
SET dd=%NOWD:~7,2%
SET yyyy=%NOWD:~10,4%

:: ECHO mm=%mm%
:: ECHO dd=%dd%
:: ECHO yyyy=%yyyy%

SET NOWT=%TIME%
SET hour=%TIME:~0,2%
SET min=%TIME:~3,2%
SET sec=%TIME:~6,2%
SET ms=%TIME:~9,2%

:: ECHO NOWT=%NOWT%
:: ECHO hour=%hour%
:: ECHO min=%min%
:: ECHO sec=%sec%
:: ECHO ms=%ms%

SET LOGFILENAME=%yyyy%%mm%%dd%_%hour%%min%%sec%%ms%.txt

:: ECHO %LOGFILENAME%

:: make sure to use a double arrow to append, not 'create'

ECHO %DATE% - %TIME% >> %LOGFILENAME%

ECHO Whatever your program should do >> %LOGFILENAME%

 

Comments [0] | | # 
# Friday, October 27, 2006
Friday, October 27, 2006 12:32:26 PM (Mountain Daylight Time, UTC-06:00) ( )

Open your command shell in Windows.

Start -> Run, CMD, <enter>

Go to a different drive, say, the D: volume, to a folder called \foo\bar

this might look like cd D:\foo\bar

Wait, I thought I said, CD, change directory.... what gives, I didn't go anywhere. When I say go, I mean go.

Here's how I go..

GO.CMD


@ECHO OFF
:: Change to 1 to display messages
SET DEBUG=0

:: Make sure there is a parameter
IF [%1]==[] GOTO MissingDir

:: If parameter 1 is a directory, it will have a nul file in it
:: If there is no nul, it's a file, not a directory
IF NOT EXIST %1\nul GOTO NotDir

:: Change working drive
:CWD
IF %DEBUG%==1 (
  ECHO %~d1
)
%~d1

:: Change working path
:CWP
cd "%~pn1"
GOTO :EOF

:: Missing a parameter
:MissingDir
ECHO You did not specify a place to go to
GOTO :Usage

:: Invalid Parameter
:NotDir
ECHO You specified a file, or an invalid directory
GOTO :EOF

:Usage
go.cmd DRIVE:\FULL\PATH\TO\FOLDER
GOTO :EOF

:End

Now, you can go anywhere, really...


Edit (12/18/2006)

This is really helpful, but I found myself using far too many keystrokes to open a console at the location in my clipboard.

Start + R -> cmd -> {ENTER} -> GO{SPACE}, ALT + E + P, {ENTER}... thats 12 keys to press to do this

Added an additional file to my %USERHOME% to automate this.

%USERHOME%\cgo.bat

cmd /k "c:\utils\go.cmd %1 && cls"

Now we're more like

Start + R -> cgo {SPACE} CTRL + V {ENTER}... Thats 9 keys. Thats a 25% reduction, and well worth my time in the one line script & the time documenting.

This saves me 1-3 seconds time I use it (average of 32)... amazing.

 

 

Comments [0] | | # 
# Friday, October 13, 2006
Friday, October 13, 2006 4:43:18 PM (Mountain Daylight Time, UTC-06:00) ( )

Here's the dealio.

We1 have a bad habit of placating the customer instead of educating them. 9 times out of 10, our customers don't know what they need. If they think they know what they want, they can't express it. Even when we've already built something, they can't express how they want to reuse it.

ed‧u‧cate –verb (used with object) ( http://dictionary.reference.com/browse/educate)
1. to develop the faculties and powers of (a person) by teaching, instruction, or schooling.

pla‧cate –verb (used with object) ( http://dictionary.reference.com/browse/placate) to appease or pacify, esp. by concessions or conciliatory gestures.

It's no suprise why there's a great deal of frustration from both parties. What would happen if we took our jobs as an opportunity to educate people, as to what was going on, by giving them rich tools with which to express what we were doing. If we could put tools in their hands to describe in their language, what we're doing, we could re-use the tools we build much quicker. Simply amazing.


1We refers to humanity in general. Especially those of us that work with any kind of customer.
Comments [0] | | #