Search found 21 matches

by Shohreh
07 Jun 2020 04:38
Forum: DOS Batch Forum
Topic: Redirect output to file without using > sign?
Replies: 12
Views: 741

Re: Redirect output to file without using > sign?

The problem is that an input file may contain tens of thousands of track points, ie. latitude + longtidude tuples.

Maybe I should just forget about cmd batch files for this task, and require installing a full scripting language like Perl or Python.
by Shohreh
07 Jun 2020 04:12
Forum: DOS Batch Forum
Topic: Redirect output to file without using > sign?
Replies: 12
Views: 741

Re: Redirect output to file without using > sign?

Can method #2 be modified somehow to include a call to grep in the middle, so that I can fetch track points from GPX files, insert them, and then append the end of the structure? @Echo OFF (For /F "Skip=2 Tokens=2 Delims=<>" %%A in (%~F0) Do Echo/^<%%A^>)>Output.xml Goto :EOF :<?xml version="1.0" en...
by Shohreh
07 Jun 2020 03:42
Forum: DOS Batch Forum
Topic: Redirect output to file without using > sign?
Replies: 12
Views: 741

Re: Redirect output to file without using > sign?

It almost works: The first line ("xm version") requires question marks, but for some reason, the line is missing in the output file. Is it due to the question mark? @ECHO OFF if "%~1"=="" GOTO PARAM (For %%A in ( "<?xml version="1.0" encoding="UTF-8"?>" "<gpx>" "<trk>" "<trkseg>" ) Do Echo/%%~A)>out...
by Shohreh
07 Jun 2020 02:36
Forum: DOS Batch Forum
Topic: Redirect output to file without using > sign?
Replies: 12
Views: 741

Re: Redirect output to file without using > sign?

Thanks, but it doesn't work on my Windows 7 computer: C:\>test2.bat >test2.xml The syntax of the command is incorrect. REM test2.bat @ECHO OFF ECHO <?xml version="1.0" encoding="UTF-8"?> ECHO <gpx> ECHO <trk> ECHO <trkseg> ECHO <trkpt lat="46.361004" lon="-1.180605"> ECHO </trkpt> ECHO </trkseg> ECH...
by Shohreh
06 Jun 2020 07:56
Forum: DOS Batch Forum
Topic: Redirect output to file without using > sign?
Replies: 12
Views: 741

Redirect output to file without using > sign?

Hello, I'd like to use a batch file to write an XML file, but without having to rely on the usual > sign because then, every sign must be escaped: @ECHO OFF ECHO ^<?xml version="1.0" encoding="UTF-8"?^> > test.gpx ECHO ^<gpx^> >> test.gpx ECHO ^</gpx^> >> test.gpx Can Windows be told to simply outpu...
by Shohreh
27 May 2020 12:12
Forum: DOS Batch Forum
Topic: [SOLVED] SET adds space to variable?
Replies: 2
Views: 498

Re: SET adds space to variable?

Thank you.
by Shohreh
27 May 2020 09:51
Forum: DOS Batch Forum
Topic: [SOLVED] SET adds space to variable?
Replies: 2
Views: 498

[SOLVED] SET adds space to variable?

Hello, In a FOR loop, I need to create a couple of variables so I can make use of them later. For some reason, the following adds a space between the left side of the filename and its extension: REM c:\test.bat input.txt FOR %%f IN ("%1") DO SET left=%%~nf & SET ext=%%~xf ECHO %left%%ext% REM Displa...
by Shohreh
30 Apr 2020 08:36
Forum: DOS Batch Forum
Topic: Can SET be filled by a command?
Replies: 6
Views: 1574

Re: Can SET be filled by a command?

Thanks, it worked. But it displays 1) the fully qualified filenames (I don't need the path) and 2) it starts by displaying "!LIST! "%__DIR"". The following gets rid of the path: for %%x in (%__dir__%*) do set LIST=!LIST! "%%x" The following doesn't work, although I need to filter files: for %%x in (...
by Shohreh
29 Apr 2020 15:01
Forum: DOS Batch Forum
Topic: Can SET be filled by a command?
Replies: 6
Views: 1574

Re: Can SET be filled by a command?

Actually, in the same vein, I also need to call a command that expects a list of files at the end: myapp.exe file1.png file2.png etc. I tried the following, but it's not obviously full of data I don't need. FOR /F "delims=" %%a IN ('dir *.png') DO set "name=%%a" & echo %name% What's a good way to bu...
by Shohreh
29 Apr 2020 14:05
Forum: DOS Batch Forum
Topic: Can SET be filled by a command?
Replies: 6
Views: 1574

Re: Can SET be filled by a command?

Thank you!
by Shohreh
29 Apr 2020 06:46
Forum: DOS Batch Forum
Topic: Can SET be filled by a command?
Replies: 6
Views: 1574

Can SET be filled by a command?

Hello,

I was wondering if SET can be filled by the output of a command?

I tried this, without success:

Code: Select all

SET count=myapp.exe input.pdf
echo %count
Thank you.
by Shohreh
11 Mar 2020 08:14
Forum: DOS Batch Forum
Topic: [SOLVED] Using GNU grep in a Windows batch script?
Replies: 9
Views: 4869

Re: [SOLVED] Using GNU grep in a Windows batch script?

For some reason, the following code works OK when calling it with either "*.gpx" or a specific filename with no spaces in (inputfile.gpx), but breaks if it holds spaces. The problem seems to come from %%f in the replacement passed to ssed: REM OK when called with my.bat "*.gpx" or my.bat inputfile.g...
by Shohreh
06 Mar 2020 10:47
Forum: DOS Batch Forum
Topic: [SOLVED] [regex] Multiline seeking with (s)sed?
Replies: 8
Views: 3599

Re: [regex] Multiline seeking with (s)sed?

Thanks both for the idea of first rearranging the input data to make parsing easier!