7,395 reputation
43571
bio website
location
age
visits member for 4 years, 1 month
seen 21 mins ago

Aug
18
comment Script to Find Certain words and delete those lines in a file
Try that to delete all lines starting with @ - here. for /f "delims=" %f in (ab.txt) do @(set a=%f && IF NOT "!a:~0,1!" =="@" ECHO !a!) And for words starting with @ hmm not sure off hand.
Aug
18
comment Batch Script to Trim lines in text to first 30 or 50 characters only
Let us continue this discussion in chat.
Aug
18
comment Batch Script to Trim lines in text to first 30 or 50 characters only
@SuperUserMan I suppose not but then you can add the " on at the end. The funny thing with cut is it doesn't cut, in the sense that it doesn't remove characters. It shows characters. But notice also my one didn't 'cut' either, it showed just the first n characters, then added a quote character. I suppose it could go wrong if you had a very short line with a quote character. like abc" and wanted to trim the first 10 characters, you'd end up with two quotes. So whether with cut or my batch, one would have to say if line length < trim amount then don't add a quote. or don't trim.
Aug
18
comment Batch Script to Trim lines in text to first 30 or 50 characters only
escaping can also be something you do to a literal character to get its special meaning.. As an example, open cygwin and do $ echo -e 'abc\ndef'<ENTER> and putting the \ before the n, makes \n, which is read as a new line, not just a regular 'n'.
Aug
18
comment Batch Script to Trim lines in text to first 30 or 50 characters only
The ^" well, you could always try ". But " has a special meaning, and to just give a plain " without any special meaning, you do what is called 'escaping' you escape it. And to escape it, you use the escape character, which in cmd.exe is ^. So, ^" is what I did there. I did ^" instinctively but generally you'd know you need to when you get errors not doing so. Getting batch files to do what you want is in some ways more difficult than programming. 'cos with programming you have a compiler that gives error messages and also you don't have the sillyness that i've described like needing !var!
Aug
18
comment Batch Script to Trim lines in text to first 30 or 50 characters only
@SuperUserMan I know an easy way not in batch.. which is you get gnuwin32 which gives you utilities that linux users use, and look for the cut command. echo abc | cut -c 2-2 gives you 'b'. (obviously gives from character 2, to character 2, inclusively).
Aug
18
comment Batch Script to Trim lines in text to first 30 or 50 characters only
The exclamation marks are something completely ridiculous about batch that is a surprise to programmers. Normally you'd do %var% as in your variable surrounded by percentages. But in -some- cases, that doesn't work like using %var% within a for or if can be funny, and when that happens you have to A)have this line setlocal enableextensions enabledelayedexpansion and B)use !var! instead of %var% And if you are running things just in cmd.exe and you want !var! to work you need to do cmd /v:on then you can do echo !var!
Aug
18
comment Batch Script to Trim lines in text to first 30 or 50 characters only
@SuperUserMan some of these are things that are unique to batch.. If you try something from cmd, you use %f, if you try something in a batch you see it doesn't work, and that you should use %%f in batch. You can try it with any simple line, from the command line vs from batch file. And it can be %a or whatever for %a in (a.txt) do echo %a. In batch you use %%a.
Aug
18
comment Batch Script to Trim lines in text to first 30 or 50 characters only
to learn programming or scripting you have to break things down and build simple things grass up. So to understand it properly, the best way isn't so much to get a broken down explanation of every line.. But to write something simple yourself and to build it up. So you start by trying to understand something very simple. Like a for statement that dumps every line of a file (not trimming). And you look at how, given a variable e.g. a=abcdefg how do you output just part of it. like just the first 3 characters.
Aug
18
revised Batch Script to Trim lines in text to first 30 or 50 characters only
added 605 characters in body
Aug
18
revised Batch Script to Trim lines in text to first 30 or 50 characters only
added 605 characters in body
Aug
18
answered Batch Script to Trim lines in text to first 30 or 50 characters only
Aug
18
comment Batch Script to Trim lines in text to first 30 or 50 characters only
this line may help cmd /v:on then for /f %f in (a.txt) do @(set a=%f & echo !a:~0,3!) though not there yet.. but it gives the first 3 char of each line. This variation trims some characters off for /f %f in (a.txt) do @(set a=%f & echo !a:~1,-2!)
Aug
18
comment Batch Script to Trim lines in text to first 30 or 50 characters only
@OuldAbba add a new line?! He said nothing about adding a new line! He said trim. and create a file with the trimmed lines. if you know then it'd benefit the questioner and anybody reading, to see your answer.
Aug
18
comment Batch Script to Trim lines in text to first 30 or 50 characters only
Well why don't either of you e.g. @Paul or ould, say how to make a for loop that tokenizes by character
Aug
14
awarded  Popular Question
Aug
13
awarded  Popular Question
Aug
13
comment Windows 7 sleeping during operations
broken link broken link (I said it twice 'cos character min limit)
Aug
13
asked Will a Windows (7,XP) computer go to sleep or standby, while copying a file?
Aug
11
comment Why won't my battery charge when plugged into a knockoff AC adapter?
@MarkS to double check, have you tried with linux e.g. a linux usb bootable? you'd get the bios unrecognized battery.. but do you also get the light lit temporarily? I suppose the problem -with both symptoms- would be with ubuntu too.. and would just confirm what you said that it's hardware. "sunny" posted a comment as a question, now removed, asking if the same problem occurred with linux.