Search found 4054 matches

by Squashman
25 Sep 2020 11:28
Forum: DOS Batch Forum
Topic: batch file inserting new lines before a string in text file
Replies: 7
Views: 1143

Re: batch file inserting new lines before a string in text file

I am using the same code, but in my case ti need to add some lines after the founded string (word) It is as simple as flipping the two lines of code. The if condition has to follow the output of the line of code you are testing. So just reverse these two lines. if "%%~a"=="z 10" >>"%outputfile%" ec...
by Squashman
22 Sep 2020 10:36
Forum: DOS Batch Forum
Topic: How to use a POST request in batch with curl.exe?
Replies: 7
Views: 129

Re: How to use a POST request in batch with curl.exe?

Curl is part of Windows 10 already.

Code: Select all

C:\>where curl.exe
C:\Windows\System32\curl.exe
by Squashman
12 Sep 2020 09:43
Forum: DOS Batch Forum
Topic: help with metadata
Replies: 1
Views: 200

Re: help with metadata

And what third party software are you using to accomplish this task? A batch file by itself is not capable of doing this alone.
by Squashman
10 Sep 2020 22:28
Forum: DOS Batch Forum
Topic: Case sensitive comparison-why doesn't this work?
Replies: 2
Views: 211

Re: Case sensitive comparison-why doesn't this work?

String substitution is not case sensitive.

Code: Select all

H:\>set "string=aaaa"

H:\>echo %string:A=A%
AAAA
So in your case it will always remove it.
by Squashman
10 Sep 2020 19:22
Forum: DOS Batch Forum
Topic: Setting variable problem in .bat or .cmd script ?
Replies: 1
Views: 162

Re: Setting variable problem in .bat or .cmd script ?

You can see the proper syntax for a command by typing the command name followed by a question mark from the cmd prompt. if /? But it is usually a lot easier just to reference Microsoft's documentation but I usually use SS64. https://ss64.com/nt/ IF NOT DEFINED variable3 set "variable3=0" echo %varia...
by Squashman
09 Sep 2020 21:15
Forum: DOS Batch Forum
Topic: command retunrs no value even though entry exists
Replies: 14
Views: 484

Re: command retunrs no value even though entry exists

Should we assume the Source Path variable is defined correctly?

Regardless, I copied and pasted your input file and your code exactly and substituted my own source path and it works just fine.
by Squashman
09 Sep 2020 17:55
Forum: DOS Batch Forum
Topic: A problem with symlink script
Replies: 6
Views: 355

Re: A problem with symlink script

I think your best option is to ask the developer to fix his program.
by Squashman
09 Sep 2020 07:32
Forum: DOS Batch Forum
Topic: Making a program process multipe files and........can I ask for assitance
Replies: 8
Views: 421

Re: Making a program process multipe files and........can I ask for assitance

Yes!!!!!!!!!!!! in 8 minutes this FORFILES /m *.txt /C "TXTlogToCSVtool /c @file @fname.csv" processed 846 flight logs, absolutely incredible I am still dismayed how users stumble upon FORFILES to use for tasks like this. While it does accomplish the task, a basic FOR command would have sufficed an...
by Squashman
02 Sep 2020 16:14
Forum: DOS Batch Forum
Topic: Copy, duplicate, rename...all that works, but the valuecheck is missing
Replies: 8
Views: 509

Re: Copy, duplicate, rename...all that works, but the valuecheck is missing

A common way to check if a variable is a number can partially be achieved by using the DELIMS option of the FOR command.

Code: Select all

FOR /F "delims=0123456789" %%G IN ("%var%") DO echo %var% is NOT a number
But you also need to check for a leading zeros.

Code: Select all

IF "%var:~0,1%"=="0" echo %var% is NOT a number
by Squashman
01 Sep 2020 06:30
Forum: DOS Batch Forum
Topic: How to run 7Zip via Batch
Replies: 1
Views: 289

Re: How to run 7Zip via Batch

by putting quotes around the entire execution of 7zip, you are basically telling the command processor to look for an executable file named the same as everything inside the quotes. Quotes are only needed for the file paths.
by Squashman
27 Aug 2020 13:30
Forum: DOS Batch Forum
Topic: What does this Batch file do?
Replies: 8
Views: 704

Re: What does this Batch file do?

Efkay wrote:
27 Aug 2020 04:46
ShadowThief: Thank you for taking the trouble to respond and indeed I have gained a tad more information.
You essentially were given what is in the help file for the Robocopy command which you could have read yourself.
by Squashman
26 Aug 2020 18:06
Forum: DOS Batch Forum
Topic: What does this Batch file do?
Replies: 8
Views: 704

Re: What does this Batch file do?

I hate to be one of those people who say RTM, but you should read the the help file first and then ask a question as to what you don't understand about the description in the help file.
by Squashman
25 Aug 2020 07:48
Forum: DOS Batch Forum
Topic: Loop and append different string to each file?
Replies: 2
Views: 417

Re: Loop and append different string to each file?

Code: Select all

for %%G in (*.TXT) DO (
ECHO Handling %%G
IF "%%G"=="1.TXT" echo "some text" >> %%G
IF "%%G"=="2.TXT" echo "some other text" >> %%G
IF "%%G"=="3.TXT" echo "some more text" >> %%G
)
by Squashman
20 Aug 2020 10:25
Forum: DOS Batch Forum
Topic: Stop search when exact match found.
Replies: 2
Views: 444

Re: Stop search when exact match found.

Use the comma to your advantage. Use it with the string you are searching for with the FINDSTR command. for /F "Tokens=2 delims=," %%a in ('findstr /C:"Mass Effect," "%SrcPath%\folders.txt"') do set GamePath=%%a Another option would be to use both tokens to your advantage. See if the first token is ...
by Squashman
18 Aug 2020 07:05
Forum: DOS Batch Forum
Topic: Creating Shortcuts using a For Loop
Replies: 3
Views: 569

Re: Creating Shortcuts using a For Loop

With the FOR command you are missing two critical components. You need to use the /F option and you need to enclose the command within single quotes. for /F "delims=" %%X in ('dir "R:\Archived Folders\*" /AD /B') do The delims option will also be needed because of spaces in the output of the command.