Search found 86 matches
- 22 Jan 2021 03:34
- Forum: DOS Batch Forum
- Topic: %MM% v0.2a - a full-featured WinNT math macro
- Replies: 25
- Views: 61419
Re: %MM% v0.2a - a full-featured WinNT math macro
Hi everyone! Using the ideas from the thread https://www.dostips.com/forum/viewtopic.php?f=3&t=9872 , I propose an edition for the source code of %MM%: :: %MM% is a WinNT batch macro that performs mathematical and relational :: operations on large integers and decimals. It will accept either numeral...
- 18 Dec 2020 02:28
- Forum: DOS Batch Forum
- Topic: color based on file extension
- Replies: 4
- Views: 5225
Re: color based on file extension
Of course there are no single way on where to put the IF command. I think the "basic" (and not the shortest code) way is to have a separate pseudo-array for file extensions: ( Note: I did not test this, and please remove the "<-- Addition #N" in your actual code) ... set Index=1 for %%i in (Mods\*) ...
- 07 Dec 2020 09:50
- Forum: DOS Batch Forum
- Topic: out to screen and file
- Replies: 2
- Views: 4202
Re: out to screen and file
Hmm... I'm no expert, but I think you need to "duplicate" your commands like the yourcode label below. The ECHO is easy, but the SET/P is a bit complicated, just so that what you see in CMD is basically what you see at file output (in this case, file.txt). @echo off rem 5 is arbitrary (but do not us...
- 07 Dec 2020 08:54
- Forum: DOS Batch Forum
- Topic: On "color" command and errorlevel
- Replies: 8
- Views: 9563
Re: On "color" command and errorlevel
However more versatility can be achieved be defining a seperate variable for the error return as used in my findstr colorprint macro ... @T3RRY I just realized that this is macro, not that usual call "function," so yeah... I think I will just use a separate variable for error number as well. A very...
- 07 Dec 2020 07:27
- Forum: DOS Batch Forum
- Topic: On "color" command and errorlevel
- Replies: 8
- Views: 9563
Re: On "color" command and errorlevel
Errorlevel can be forced using call and parentheses. Errorlevel 1 (Call) Errorlevel 0 (Call ) I just tested this, and I just found out that (call ) (with space) is a very tiny bit slower than (call) , but the color command without parameter is obviously slow, while color 00 is fast. This makes the ...
- 07 Dec 2020 04:59
- Forum: DOS Batch Forum
- Topic: On "color" command and errorlevel
- Replies: 8
- Views: 9563
On "color" command and errorlevel
Today I revisited the amazing %mm% macro , and I had a comment there that it errors out when the Batch file is opened by clicking (unlike when opened in CMD). Upon debugging, I realized that the "bug" is on the COLOR command which is used to set the errorlevel. Example: @echo off color 00 echo(%erro...
- 09 Jan 2020 11:09
- Forum: DOS Batch Forum
- Topic: Batch file macro and SNAKE.BAT
- Replies: 2
- Views: 5060
Re: Batch file macro and SNAKE.BAT
the parenthesis are necessary in macros, when you want to use the %\n% for multiple lines. That's because a raw line feed outside parenthesis stops the parser and the remaining stuff will be dropped. From the quote, I just found out the answer to my question now (~10 days since asking :oops:). Upon...
- 31 Dec 2019 02:19
- Forum: DOS Batch Forum
- Topic: Batch file macro and SNAKE.BAT
- Replies: 2
- Views: 5060
Batch file macro and SNAKE.BAT
I am new to batch macros and researching topics here in DosTips. I am aware of Macros with parameters appended and it's awesome, but I am specifically trying to implement macros that have no parameters, just manipulate variables and/or echo something, etc. Shown below is my test: @echo off setlocal ...
- 26 Dec 2019 04:12
- Forum: DOS Batch Forum
- Topic: Bat file to create another bat file.
- Replies: 18
- Views: 18867
Re: Bat file to create another bat file.
Mount the network drive first like this: (you can change X: to any unused drive letter)
Then copy files to/from the drive letter:
After copying, unmount the network drive using this:
Meerkat
Code: Select all
net use X: "\\192.168.168.7\9xAddons"
Code: Select all
xcopy /y /f "X:\Macrium\ReflectDLHF.exe"
Code: Select all
net use X: /delete
- 28 May 2019 10:36
- Forum: DOS Batch Forum
- Topic: Need help with command line string replacement
- Replies: 3
- Views: 6588
Re: Need help with command line string replacement
Hello! First of all, I did not try to understand the code :lol: . Sorry . Upon entering for /? in CMD, you get this part: In addition, substitution of FOR variable references has been enhanced. You can now use the following optional syntax: %~I - expands %I removing any surrounding quotes (") %~fI -...
- 01 Sep 2018 21:52
- Forum: DOS Batch Forum
- Topic: %MM% v0.2a - a full-featured WinNT math macro
- Replies: 25
- Views: 61419
Re: %MM% v0.2a - a full-featured WinNT math macro
Hello! Impressive work! Maybe this was already addressed. When I open the script from CMD, the nth root works. However, when I open the script from clicking, it aborts. Finding 2th root of 10 to 4 decimals starting at 3 guess=(((2-1)*3)+(10/3$(2-1)))/2 guess#1=3.1666 guess#2=3.1622 guess#3=3.1622 Er...
- 18 Jul 2018 08:41
- Forum: DOS Batch Forum
- Topic: Batch Folders
- Replies: 1
- Views: 3621
Re: Batch Folders
See the code (I dont know how to properly start this reply!). The rem commands are comments for understanding the code, so you can remove them. I assume that this batch file is on the "projects" folder. @echo off set /p "id=Enter Project Name: " rem New code... :newcode set /p "lev=Level: " rem Inpu...
- 13 Jun 2018 12:26
- Forum: DOS Batch Forum
- Topic: Deleting folders
- Replies: 1
- Views: 3483
Re: Deleting folders
Apparently, rd/rmdir doesn't support wildcards. Change the problematic line with this instead:
Wherein for /d allows you to loop through directories. Here's a link for more information: https://ss64.com/nt/for_d.html
Meerkat
Code: Select all
for /d %%x in ("E:\Dmgr01\wstemp\anonymous*") do rmdir "%%x"
Meerkat
- 08 Apr 2018 12:38
- Forum: DOS Batch Forum
- Topic: JREPL Usage - working but is this correct?
- Replies: 3
- Views: 4665
Re: JREPL Usage - working but is this correct?
Well you can combine the two JREPL calls into one (the pipe character | means something like "or").
Meerkat
Code: Select all
CD /D "%~dp0"
call jrepl ",,|,$" "" /F "Test.csv" /O -
- 30 Jan 2017 04:44
- Forum: DOS Batch Forum
- Topic: About "Read words separated by space in a batch script"
- Replies: 1
- Views: 3851
About "Read words separated by space in a batch script"
Hello! This is about DBenham's answer in SO here: http://stackoverflow.com/a/19121445 . The code is awesome because it does not treat comma as delimiter. However, even though there is an exclamation in the file, the character is not displayed. Example.txt Rock and Roll! What am I doing in my laip? C...