Search found 158 matches

by drgt
18 Nov 2021 23:40
Forum: DOS Batch Forum
Topic: Limiting echo & Output word "on"
Replies: 6
Views: 4400

Re: Limiting echo & Output word "on"

Code: Select all

echo(on
Thanks for the alternative.
Searching for "echo the word on" (at least on the first few results) I did not see any references to the "side effects"
by drgt
14 Nov 2021 12:15
Forum: DOS Batch Forum
Topic: Limiting echo & Output word "on"
Replies: 6
Views: 4400

Re: Limiting echo & Output word "on"

Thank you for showing my omission :(
Answers
1

Code: Select all

C:\>if 2 gtr 1 (echo greater) else (echo equal or lesser)
2

Code: Select all

C:\>echo.on
by drgt
14 Nov 2021 03:35
Forum: DOS Batch Forum
Topic: Limiting echo & Output word "on"
Replies: 6
Views: 4400

Limiting echo & Output word "on"

1. How to limit what echo is to process, without splitting the line?

example

Code: Select all

Prompt:>if 2 GTR 1 echo bigger else echo lesser
result: bigger else echo lesser
2. How to echo "ON" instead of turning echo on?
by drgt
12 Nov 2021 03:22
Forum: DOS Batch Forum
Topic: Trim paths after xth \ occurence
Replies: 13
Views: 8081

Re: Trim paths after xth \ occurence

Why? It's so that you want to process a file line-wise rather than to process a single string. A quoted expression in a FOR /F without option USEBACKQ is treated as string. A quoted expression with USEBACKQ is treated as file name. Steffen GOT IT , I think! :oops: One little problem. When the sourc...
by drgt
12 Nov 2021 02:19
Forum: DOS Batch Forum
Topic: Trim paths after xth \ occurence
Replies: 13
Views: 8081

Re: Trim paths after xth \ occurence

Run each of these commands and look at the output. This should help you understand how quotes affect the FOR /F command. Thanks a lot! Running your suggestion with the following variation helped me understand. cls @echo 1 for /f "delims=" %%x in (test file.log) do echo %%x @rem The system cannot fi...
by drgt
11 Nov 2021 11:07
Forum: DOS Batch Forum
Topic: Trim paths after xth \ occurence
Replies: 13
Views: 8081

Re: Trim paths after xth \ occurence

I appreciate it for walking me through it. Maybe this way, I will understand it. I am not on my pc now but from what I recall it has to do with names with spaces? After correctly echoing %%G, will proceed with another for to truncate? I will run the code you posted when I get back but give me a hint...
by drgt
11 Nov 2021 10:35
Forum: DOS Batch Forum
Topic: Trim paths after xth \ occurence
Replies: 13
Views: 8081

Re: Trim paths after xth \ occurence

A "for" within a "for" is partly the answer?
by drgt
11 Nov 2021 10:16
Forum: DOS Batch Forum
Topic: Trim paths after xth \ occurence
Replies: 13
Views: 8081

Re: Trim paths after xth \ occurence

It flaters me that you think highly of me.
In reality I am not worth it.
It is Chinese to me.

Code: Select all

for /f "tokens=6* delims=\" %%i in ("T1.log") do echo "%%j" >T2.log
did not work :(
by drgt
11 Nov 2021 07:23
Forum: DOS Batch Forum
Topic: Trim paths after xth \ occurence
Replies: 13
Views: 8081

Trim paths after xth \ occurence

Yes, but what is being asked is to process each entry in, say, t1.log, and create t2.log with the modified entries.
by drgt
11 Nov 2021 04:39
Forum: DOS Batch Forum
Topic: Trim paths after xth \ occurence
Replies: 13
Views: 8081

Trim paths after xth \ occurence

A text file contains lines in double quotes.
Within the quotes a path is contained.
Using a batch file I would like to create another text file also containing paths in double quotes, BUT truncating the entries by removing anything beyond the 6th backslash including the 6th backslash.
Can it be done?
by drgt
10 Nov 2021 00:15
Forum: DOS Batch Forum
Topic: Copy / Move Maintaining Tree structure
Replies: 3
Views: 2956

Copy / Move Maintaining Tree structure

The problem with this, I think, is that it must be specified where to start copying to. I mean: Does the system create <target path> append <source path> in which case the result will be C:\user\desktop\FolderB\user\desktop\FolderA\1\2 That is not the desired result. So, in addition to the "text.log...
by drgt
09 Nov 2021 22:31
Forum: DOS Batch Forum
Topic: Copy / Move Maintaining Tree structure
Replies: 3
Views: 2956

Copy / Move Maintaining Tree structure

xcopy "C:\user\desktop\FolderA\1\2" "C:\user\desktop\FolderB" /t /e copies nothing. xcopy "C:\user\desktop\FolderA\1\" "C:\user\desktop\FolderB" /t /e copies folder 2 to target, not 1\2. xcopy "C:\user\desktop\FolderA\" "C:\user\desktop\FolderB" /t /e copies unwanted subfolders of folderA too. Remem...
by drgt
09 Nov 2021 02:51
Forum: DOS Batch Forum
Topic: Move errorlevel in For Statement
Replies: 5
Views: 4094

Move errorlevel in For Statement

That is really a nice TRICK! By the way, I thought the open parenthesis before "for" was a typo BUT IS REQUIRED for it to work correctly, otherwise it works like in post 1. The DO commands never execute because the file is empty so the FOR command has nothing to parse. On second thought, I would thi...
by drgt
09 Nov 2021 02:12
Forum: DOS Batch Forum
Topic: Copy / Move Maintaining Tree structure
Replies: 3
Views: 2956

Copy / Move Maintaining Tree structure

How to copy a folder to target maintaining specified path tree (with the tree folders to be copied empty even if they contain files) Example: A dir command creates a text.log with an entry: "C:\user\desktop\FolderA\1\2" It is asked to Copy / Move C:\user\desktop\FolderA\1\2 to C:\user\desktop\Folder...
by drgt
07 Nov 2021 00:33
Forum: DOS Batch Forum
Topic: Move errorlevel in For Statement
Replies: 5
Views: 4094

Re: Move errorlevel in For Statement

I see.
So what is the workaround for the zero subroutine?