Search found 3494 matches

by aGerman
16 Jun 2019 14:47
Forum: DOS Batch Forum
Topic: BATCH DOES NOT START
Replies: 1
Views: 8

Re: BATCH DOES NOT START

In a command line FOR variables have one preceding percent sign (e.g. %a) while in a Batch script they need to have two (e.g. %%a).

Steffen
by aGerman
12 Jun 2019 09:45
Forum: DOS Batch Forum
Topic: Batch file with config file
Replies: 2
Views: 115

Re: Batch file with config file

You can't execute a txt file. And since you didn't say anything about its content we don't even know whether it contains any executable script code. If it contains Batch code then rename it with extension bat and call it.

Steffen
by aGerman
10 Jun 2019 16:29
Forum: DOS Batch Forum
Topic: Copying a file from a folder with today's date to another folder.
Replies: 2
Views: 108

Re: Copying a file from a folder with today's date to another folder.

You can use the wmic command to work around localized date formats.

Code: Select all

@echo off &setlocal
for /f %%i in ('wmic os get localdatetime /value') do for /f %%j in ("%%i") do set %%j
copy /y "C:\monitoring\%localdatetime:~4,4%%localdatetime:~,4%\hg200T.csv" "C:\warning\excel\stream\"
Steffen
by aGerman
10 Jun 2019 10:38
Forum: DOS Batch Forum
Topic: Modifying batch to accommodate for any subfolder with "classified" in its name
Replies: 7
Views: 117

Re: Modifying batch to accommodate for any subfolder with "classified" in its name

Check your paths for typos, make sure there are no characters in the folder names that are not supported (preferably use ASCII only), make sure the paths exist (e.g. don't mess up "C:\My Documents" and "%userprofile%\Documents").

Steffen
by aGerman
10 Jun 2019 07:36
Forum: DOS Batch Forum
Topic: Modifying batch to accommodate for any subfolder with "classified" in its name
Replies: 7
Views: 117

Re: Modifying batch to accommodate for any subfolder with "classified" in its name

I created folder "C:\My Documents" and subfolders "barclassifiedfoo", "foobar", and "fooclassifiedbar" inside of it. Then I run the above code. It created "subfolder1", "subfolder2", and "subfolder3" in both "barclassifiedfoo" and "fooclassifiedbar" as expected.

Steffen
by aGerman
10 Jun 2019 07:00
Forum: DOS Batch Forum
Topic: Modifying batch to accommodate for any subfolder with "classified" in its name
Replies: 7
Views: 117

Re: Modifying batch to accommodate for any subfolder with "classified" in its name

Untested: @echo off setlocal set "parentfolder=C:\My Documents" set "pattern=*classified*" pushd "%parentfolder%" for /F "tokens=*" %%G in ('dir "%pattern%" /A:D /B') do ( if not exist "%%G\subfolder1" md "%%G\subfolder1" if not exist "%%G\subfolder2" md "%%G\subfolder2" if not exist "%%G\subfolder3...
by aGerman
10 Jun 2019 06:17
Forum: DOS Batch Forum
Topic: Modifying batch to accommodate for any subfolder with "classified" in its name
Replies: 7
Views: 117

Re: Modifying batch to accommodate for any subfolder with "classified" in its name

Try

Code: Select all

md "%%~fG\subfolder1"
You may have to PUSHD to the parent folder first. Otherwise there is a risk that modifier ~f doesn't expand to the right directory.

Steffen
by aGerman
10 Jun 2019 06:06
Forum: DOS Batch Forum
Topic: CONVERTCP.exe - Convert text from one code page to another
Replies: 84
Views: 31436

Re: CONVERTCP.exe - Convert text from one code page to another

Most of the current command line utilities don't support Virtual Terminal processing yet. In this case ANSI escape sequences are not used to control the console output and their textual expressions get printed to the screen. Example using an old version: >nul chcp 65001 echo +ABsAWw-93;42m+JYgliCWIJ...
by aGerman
04 Jun 2019 11:46
Forum: DOS Batch Forum
Topic: Check if a batch completed successfully (and was not closed by the user.
Replies: 8
Views: 308

Re: Check if a batch completed successfully (and was not closed by the user.

You said it's sequential. If the script failed or was interrupted, would you be able to begin somewhere in the middle of the sequences? For me it's all like crystal-ball gazing because I don't have any context. So, I still don't understand the sense of a flag. My understanding: caller.bat @echo off ...
by aGerman
04 Jun 2019 04:03
Forum: DOS Batch Forum
Topic: Check if a batch completed successfully (and was not closed by the user.
Replies: 8
Views: 308

Re: Check if a batch completed successfully (and was not closed by the user.

I still don't get the problem. If main.bat was interrupted and the encrypted output was corrupted, then nothing happens because the entire script flow was terminated and the corrupted output will not be used in subsequent tasks of the script. What do I miss here?

Steffen
by aGerman
03 Jun 2019 16:46
Forum: DOS Batch Forum
Topic: Check if a batch completed successfully (and was not closed by the user.
Replies: 8
Views: 308

Re: Check if a batch completed successfully (and was not closed by the user.

I do not think that there is any need to know what main.bat is Maybe not. But It's definitely important to know how you call it. Is it via double click? Or do you call it from within another script? And what shall happen if the script failed or was terminated before it finished the encryption task?...
by aGerman
03 Jun 2019 12:44
Forum: DOS Batch Forum
Topic: Check if a batch completed successfully (and was not closed by the user.
Replies: 8
Views: 308

Re: Check if a batch completed successfully (and was not closed by the user.

The checker.bat was closed by the user. And now you need a check_checker.bat to observe it, right? And you will likely need a check_check_checker.bat, too. So, no that doesn't sound reasonable. Your real ultimate goal is to get the content of main.bat executed, and you really should tell us about wh...
by aGerman
03 Jun 2019 12:28
Forum: DOS Batch Forum
Topic: Text Files - Coloured Characters
Replies: 6
Views: 431

Re: Text Files - Coloured Characters

As long as you still stick with XP you're out of luck. ANSI escape sequences are supported on Windows 10 version 10.0.10586 onwards. If you don't want to use 3rd party tools on older Windows versions then check out FINDSTR /A workarounds like these https://www.dostips.com/forum/viewtopic.php?p=41155...
by aGerman
02 Jun 2019 13:45
Forum: DOS Batch Forum
Topic: Batch file runs differently when executed line by line
Replies: 6
Views: 393

Re: Batch file runs differently when executed line by line

Consider to call the batch script from the command prompt instead. There are lines in the script that can't be written as command lines.

Steffen
by aGerman
02 Jun 2019 13:39
Forum: DOS Batch Forum
Topic: Help for loop replace string
Replies: 1
Views: 236

Re: Help for loop replace string

Use
echo(!line!
instead of
echo !line!

Steffen