17
votes
4answers
43k views

Delete certain lines in a txt file via a batch file

I have a generated txt file. This file has certain lines that are superfluous, and need to be removed. Each line that requires removal has one of two string in the line; "ERROR" or "REFERENCE". ...
16
votes
5answers
14k views

How do you get the string length in a batch file?

There doesn't appear to be an easy way to get the length of a string in a batch file. E.g., SET MY_STRING=abcdefg SET /A MY_STRING_LEN=??? How would I find the string length of MY_STRING? Bonus ...
7
votes
2answers
10k views

2 batch string questions

1) Is there any built-in which can tell me if a variable's contents contain only uppercase letters? 2) is there any way to see if a variable contains a string? For example, I'd like to see if the ...
4
votes
4answers
8k views

How do I perform string operations on variables in a for loop?

This sounds dumb, but I can't get it to work. I think i just dont' understand the difference between %%v, %v% and %v Here's what I'm trying to do: for %%v in (*.flv) do ffmpeg.exe -i "%%v" -y -f ...
3
votes
2answers
4k views

Get filename from string-path?

How do I get the filename from this string? "C:\Documents and Settings\Usuario\Escritorio\hello\test.txt" output: "test.txt" I really tried to find this one before posting, but all the results ...
3
votes
3answers
4k views

DOS batch script to parse CSV file and output a text file

I've seen a response on another page (http://stackoverflow.com/questions/6470570/help-in-writing-a-batch-script-to-parse-csv-file-and-output-a-text-file) - brilliant code BTW - : @ECHO OFF IF ...
3
votes
2answers
3k views

Parse PATH using FOR /F in BAT script

I need to parse the %PATH% list in a .BAT script, but I'm not having much luck with paths that contain spaces. for %%a in (%PATH%) do @echo %%a The above parses on spaces (default), but I need to ...
3
votes
2answers
538 views

Combine multiple lines from one text file into one line

So I have a file with multiple lines of letters and numbers as shown: a 1 h 7 G k 3 l END I need a type of code that combines them together and preferably outputs it into a variable as shown: ...
3
votes
1answer
368 views

How can I perform concatenation on numbers in batch?

For example, I have the numbers 5, 3, 8, 2, 7, 4 and 9 which I got from operations such as 2+2, 7-2 and 3*3, etc... They are all stored in variables. I want to know if there is a way I can dynamically ...
2
votes
5answers
125 views

How to split string in a variable without loosing spaces?

how can i split the string " This is a text with spaces " that is in the variable "string" into text parts without loosing the spaces ? set string="# This is a text with spaces ...
2
votes
2answers
745 views

How to find if a string is in a list of strings in a DOS batch file

I'd like to check if an argument to a batch file is valid based on a list of strings. For example: IF %1 IN validArgument1, validArgument2, validArgument3 SET ARG=%1 This would set ARG to one of ...
2
votes
4answers
3k views

bat file to replace string in text file

This question has been asked a lot on stackoverflow, but I can't seem to be able to make it work. Any hints appreciated. Here is a text file (extension .mpl) containing offending text that needs to be ...
2
votes
1answer
4k views

In a batch file, Combining two strings to create a combined path string

I need to take two strings and combine them into a single path string inside a batch file similar to the Path.Combine method in .Net. For example, whether the strings are "C:\trunk" and ...
2
votes
3answers
228 views

cmd string replacement of special character

I am trying to replace ~ with %HOME% in a batch script. This is what I have so far: @echo off setlocal enabledelayedexpansion set str=%* set replacement=%HOME% set str=%str:~=!replacement!% echo ...
2
votes
2answers
3k views

Batch file string manipulation

This is a very specific question, however; Say I have a batch file running from\located in the directory c:\data\src\branch_1 How do I set my environment variable %buildpath% to ...

1 2 3 4 5 9
15 30 50 per page