Search found 4316 matches

by Squashman
15 May 2024 08:28
Forum: DOS Batch Forum
Topic: netsh Interface name store as variable
Replies: 10
Views: 12252

Re: netsh Interface name store as variable

Based on your initial netsh output you do not have any interfaces that are "Connected" and are "Ethernet" What output are expecting when nothing matches?
by Squashman
03 May 2024 16:36
Forum: DOS Batch Forum
Topic: Need help with misbehaving DOS code
Replies: 2
Views: 798

Re: Need help with misbehaving DOS code

Test if you have shifted out all the arguments before you goto the loop.

Code: Select all

SHIFT
IF NOT "%~1"=="" GOTO loop
And the first two rules of debugging a batch file.
1) Do not run the batch file with your mouse. Open up a command prompt and run it from there.
2) Use ECHO ON at the top of your script.
by Squashman
08 Apr 2024 10:20
Forum: DOS Batch Forum
Topic: Success or failure echo
Replies: 3
Views: 776

Re: Success or failure echo

Robocopy has multiple return codes.
https://ss64.com/nt/robocopy-exit.html
by Squashman
08 Apr 2024 07:32
Forum: DOS Batch Forum
Topic: DONT WORK: string input / if construct: output part of string with variable
Replies: 1
Views: 597

Re: DONT WORK: string input / if construct: output part of string with variable

Well you have delayed expansion enabled. It would help if you used it.

Code: Select all

if !string:~%counter%,1! EQU 1
by Squashman
04 Apr 2024 08:46
Forum: DOS Batch Forum
Topic: how do i get the filesize from a filename? and compare with IF statement
Replies: 2
Views: 687

Re: how do i get the filesize from a filename? and compare with IF statement

Surprised your searching did not find any of these links. It is right on the main DosTips.com site library. https://www.dostips.com/?t=Snippets.FileSize As well as discussed in several threads. Here is one of them. https://www.dostips.com/forum/viewtopic.php?t=9274 No clue why you would assign the s...
by Squashman
15 Mar 2024 12:47
Forum: DOS Batch Forum
Topic: path to hosts file from script
Replies: 3
Views: 1248

Re: path to hosts file from script

%systemroot% is a variable which means you need double expansion.

Code: Select all

if "%%~a"=="DataBasePath" CALL set "hostspath=%%b"
by Squashman
05 Mar 2024 14:05
Forum: DOS Batch Forum
Topic: How to debug this bat file
Replies: 6
Views: 3201

Re: How to debug this bat file

Thank you for the reply... If I add ^ infront of the problematic characters (, ), | What would the line look like? I'm not familiar with that character. Isn't that line a remark? Why would the cmd interpreter care what characters are in a remark? Thank you, Are you saying you are not familiar with ...
by Squashman
29 Feb 2024 16:50
Forum: DOS Batch Forum
Topic: How to put path with blanks into "for" command? Masking & quotes
Replies: 9
Views: 6718

Re: How to put path with blanks into "for" command? Masking & quotes

mataha wrote:
29 Feb 2024 16:24
Escaping the quotes shouldn't be necessary:

Code: Select all

for /f delims^= %%g in ('""D:\some\path\with blanks inside\myprog.exe" -p "......" %1"') do set "....."
We have a discussion about it here on DosTips. I will see if I can dig up that thread.
by Squashman
28 Feb 2024 17:47
Forum: DOS Batch Forum
Topic: How to read a txt file to sort out the string then output to a folder with some txt files
Replies: 9
Views: 2892

Re: How to read a txt file to sort out the string then output to a folder with some txt files

OK I see now. I just had another issue when the fist line string has one space at the end. the folder will become 5 digits Schemes_to_Sign_for_829501 the folder will be 29501. Anyway to cut off the space before set it as folder? I bet if you use the sites search capability you will find all kinds o...
by Squashman
28 Feb 2024 13:34
Forum: DOS Batch Forum
Topic: How to compare 2 modified file timestamps?
Replies: 6
Views: 2575

Re: How to compare 2 modified file timestamps?

I should have known we answered this question before.
Compare timestamps of two files (seconds too)
by Squashman
28 Feb 2024 13:21
Forum: DOS Batch Forum
Topic: How to put path with blanks into "for" command? Masking & quotes
Replies: 9
Views: 6718

Re: How to put path with blanks into "for" command? Masking & quotes

An extra set of escaped double quotes would have done the trick.

Code: Select all

for /F "Tokens=*" %%G in (' ^""D:\some\path\with blanks inside\myprog.exe" -p "......" %1^"') do set "....."
by Squashman
28 Feb 2024 13:12
Forum: DOS Batch Forum
Topic: How to compare 2 modified file timestamps?
Replies: 6
Views: 2575

Re: How to compare 2 modified file timestamps?

This will not get seconds. Only has minute precision.

Code: Select all

for %%G in ("aaaa.dat") do for /f "tokens=1-5 delims=/: " %%H IN ("%%~tG") do set "aaaats=%%J%%H%%I%%K%%L"
by Squashman
27 Feb 2024 13:44
Forum: DOS Batch Forum
Topic: How to read a txt file to sort out the string then output to a folder with some txt files
Replies: 9
Views: 2892

Re: How to read a txt file to sort out the string then output to a folder with some txt files

Thanks a lot! Antonio! Yes works perfefectly! Just a quick question for this line for /F "delims=\" %%a in ('findstr "_ ." source.txt') do ( So what is this 'findstr "_ ."? the rest I can understand.... Thanks again! Will You could help yourself by reading the help for the FINDSTR command. Use spac...