Wednesday 12 March 2008

more batch goodness!

problem: app generated csv encases entries with double quotes, we want the double quotes removed... please!

what im not doing: using wsh (the client googled and suggested that i use vbs, looking nervous as they obviously didnt know what this meant).

start at the start, batch as always (i hate myself);

for /f "tokens=1* delims=," %a in (foo.sv) do echo %~a,%~b >> bar.csv

kinda easy!

Tuesday 4 March 2008

winxppro startup issue (panic panic panic)

problem: client pc starts-up to desktop (almost) and displays 'services.exe unable to start, some dll missing, blah, blah, reinstall, etc' inciting real panic and confusion... restarting the machine boots to blue screen (for a second) then restarts (as is the default setting). talk of a brand new pc ensues as i stroll into the office...

what im not doing: agreeing with a new purchase and blagging the pc, i mean i have a soul (and i think its still under warranty, so i would be filling in forms and making calls... no) also, stating the obvious, this isnt a trick or anything new, im just tracking problems and fixes.


boot of xppro cd, enter recovery console and enter the mighty;

chkdsk c: /r

and restart. job done.


thoughts - my linux distro of choice runs a similar tool every 30 mounts, winxppro would benefit from such pragmatic steps.

Monday 3 March 2008

batch magic!

problem: client has a generated csv of months credit notes issued, each item credited should be (but sometimes not due to human error) flagged as damaged, quality issue, shortage, not-as-ordered or error (*d*, *q*, *s*, *nao*, *e*). a summary of each catergory should be generated for that month. during the brief i offered a futher category of 'misc' for items not flagged and was hailed as the hero i am (for a short while).

what im not doing: playing football tonight probably... it has snowed!

batch solves the above, toffee!

setlocal enabledelayedexpansion
copy foo.csv cred.csv
set foo=foo
for %%a in (d,q,nao,s,e) do (
type !foo!.csv find /i "*%%a*" >> %%a.csv
type !foo!.csv find /i /v "*%%a*" >> "%%a%%a.csv"
del !foo!.csv
set foo=%%a%%a
)
rename ee.csv misc.csv

notes on the 'cdrill.bat'
name the initial file 'foo.csv'
need setlocal or the variable expands to 'e' instantly
piping output of type for tidyness (no ----- blah.csv at head of file as when 'find' is used), pipe doesnt seem to show up in post