Search found 1761 matches

by penpen
16 Jul 2013 18:27
Forum: DOS Batch Forum
Topic: A different method to trim spaces from a string
Replies: 16
Views: 7614

Re: A different method to trim spaces from a string

Is it any safer if we just pass the name of the variable whose value is to be trimmed rather than the value itself? Much better, i have tested all tricks, i remembered, on your safetrim.bat: @echo off set x=%1 for /f "tokens=1* delims==" %%a in ( 'set %1' do call :exec %%b goto :EOF :exec...
by penpen
16 Jul 2013 17:00
Forum: DOS Batch Forum
Topic: CSV to QIF Using Batch?
Replies: 9
Views: 4072

Re: CSV to QIF Using Batch?

Do you mean with CSV and QIF the Comma-Separated Values format and the Quicken Interchange Format? If yes, i assume this conversion is possible IF you have a specification for the comma-separated values format. The problem would be to define a clean specification to hold the same data as the QIF, as...
by penpen
16 Jul 2013 16:36
Forum: DOS Batch Forum
Topic: Merge .txt files in folders, adding commas and quotationmark
Replies: 8
Views: 3403

Re: Merge .txt files in folders, adding commas and quotation

Just help those closest to you as much as you can, as much as you want! :D

Regards,
penpen.
by penpen
16 Jul 2013 16:30
Forum: DOS Batch Forum
Topic: Run Batch File at Specific Time
Replies: 7
Views: 4837

Re: Run Batch File at Specific Time

If you count all executables in %SystemRoot%\system32 to pure command line dos i would prefer cscript.exe: @if (true == false) then /* @echo off %SystemRoot%\system32\cscript.exe //E:JScript "%~f0" "10:00" :: code to execute goto :eof */ @end if (WScript.Arguments.Unnamed.Length ...
by penpen
16 Jul 2013 15:02
Forum: DOS Batch Forum
Topic: A different method to trim spaces from a string
Replies: 16
Views: 7614

Re: A different method to trim spaces from a string

@Samir It seems to right trim only: Z:\>for %f in (" test test test ") do echo "%~nf" " test test test" @probyn This woorks very good, but is unsafe: trim asdad asd ^& echo Leak Maybe i am a little bit too mistrustful, but this is my maxime on external input. penpen...
by penpen
16 Jul 2013 13:38
Forum: DOS Batch Forum
Topic: Command 'grep' and 'awk'
Replies: 3
Views: 1813

Re: Command 'grep' and 'awk'

@Ocalabob I've only found one other forum in where pinto15 has posted the same question, and the answer is nearly Samir's first sentence. The other forum with the command line is a forum in that this command line is a result, so it should work as is: m @pinto15 I assume mingw is installed on your sy...
by penpen
16 Jul 2013 08:24
Forum: DOS Batch Forum
Topic: Merge .txt files in folders, adding commas and quotationmark
Replies: 8
Views: 3403

Re: Merge .txt files in folders, adding commas and quotation

If the lines of the textfile you want to combine are not too long (around 8192 bytes), and if the combined file should be created in the same directory then the following may help you: @echo off cls setlocal set "combined=combined.txt" ( for %%a in (*.txt) do ( if not "%%a" == &q...
by penpen
15 Jul 2013 19:01
Forum: DOS Batch Forum
Topic: For Loop
Replies: 8
Views: 2495

Re: For Loop

This is not much code to test, so i only can assume the following happens: Within a batch file every line is expanded before it is parssed, ... and executed. This means, that all variables within this line will be expanded to their values when the variable name is within % signs. A single % sign wil...
by penpen
14 Jul 2013 14:42
Forum: DOS Batch Forum
Topic: Installation
Replies: 31
Views: 6665

Re: Installation

Edit: I then ran it as an administrator and it worked, I'm now curious is there any way around requiring to run as an administrator? Obviously not. @echo off CLS move C:\Users\%USERNAME%\Desktop\test.txt "C:\Users\%USERNAME%\Program Files" set empty=Y for /F %%G in ('dir /b C:\Program Fil...
by penpen
14 Jul 2013 14:14
Forum: DOS Batch Forum
Topic: Taking input and storing an a variable
Replies: 3
Views: 1652

Re: Taking input and storing an a variable

The command setlocal does the following: Starts localization of environment variables in a batch file. Localization continues until a matching endlocal command is encountered or the end of the batch file is reached [...] So you may change variables within an setlocal-endlocal block as you want, but ...
by penpen
14 Jul 2013 12:33
Forum: DOS Batch Forum
Topic: Taking input and storing an a variable
Replies: 3
Views: 1652

Re: Taking input and storing an a variable

First: I'm not sure even where to start, I would like to know how to store given info into a variable set "variable=given info" Second: For example the user is prompted to give an input of either one or two and its then stored in a variable that can later be used set "variable that ca...
by penpen
14 Jul 2013 11:45
Forum: DOS Batch Forum
Topic: Installation
Replies: 31
Views: 6665

Re: Installation

I assume there is missing a backslash prior to test.txt.

penpen
by penpen
14 Jul 2013 08:42
Forum: DOS Batch Forum
Topic: SNAKE.BAT 4.1 - An arcade style game using pure batch
Replies: 107
Views: 197944

Re: SNAKE.BAT - An arcade style game using pure batch

Nearly forgotten: I downloaded the choice from m as it was not present on my xp home, and the game then prints: ERROR: This game requires the CHOICE command, but it is missing. Game aborted. :( usw. The tests you do to check the existance of choice produces: Z:\>choice /c:yn /t 0 /d y CHOICE:Incorre...
by penpen
14 Jul 2013 08:20
Forum: DOS Batch Forum
Topic: SNAKE.BAT 4.1 - An arcade style game using pure batch
Replies: 107
Views: 197944

Re: SNAKE.BAT - An arcade style game using pure batch

I'm not sure, but i think the error is produced because you do that in the main loop: %=== remove the new head location from the empty list ===% for %%X in ("!X!") do for %%Y in ("!Y!") do set "empty=!empty:#%%~X %%~Y=!" :: ... set /a "score+=1, F=(!random!%%emptyC...
by penpen
13 Jul 2013 15:11
Forum: DOS Batch Forum
Topic: SNAKE.BAT 4.1 - An arcade style game using pure batch
Replies: 107
Views: 197944

Re: SNAKE.BAT - An arcade style game using pure batch

You should avoid creating files, as this is slower than reading memory. This example is selfexplaining: :: source.bat @echo off setlocal rem for %%a in (a b c d e f g h i j k l m n o p q) do <nul set /p "=%%a" for %%a in (a b c d e f g) do <nul set /p "=%%a" for %%a in (h i j k l...