Search found 1866 matches

by penpen
21 Jan 2021 17:20
Forum: DOS Batch Forum
Topic: JSON file in wrong format.
Replies: 3
Views: 90

Re: JSON file in wrong format.

The following might help you:
- viewtopic.php?f=3&t=9049#p59302
- viewtopic.php?f=3&t=9049#p59297


penpen
by penpen
15 Jan 2021 17:25
Forum: DOS Batch Forum
Topic: save text file contents into a temporary variable and echo it only if that text file is modified
Replies: 2
Views: 141

Re: save text file contents into a temporary variable and echo it only if that text file is modified

Depending on the file content it might be impossible to store that within an environment variable. You could use the task scheduler to react on file changed events..., but that horribly sounds like cracking a walnut with a sledgehammer, because you would get tons of events for dozens of temporary fi...
by penpen
15 Jan 2021 17:11
Forum: DOS Batch Forum
Topic: script to delete user
Replies: 1
Views: 159

Re: script to delete user

In case noone replies, you might want to ask in a forum that typically does windows admin stuff.
If i remember right superuser.com might be able to help you.


penpen
by penpen
15 Jan 2021 17:05
Forum: DOS Batch Forum
Topic: rename extention of a file
Replies: 1
Views: 206

Re: rename extention of a file

You might do something like that (sketched and untested): @echo off setlocal enableExtensions disableDelayedExpansion set "N=1000000000" for %%a in ("*12345-*" "*-*12345") do ( for /f "tokens=* delims=" %b in ('set /a "N"') do ( echo(ren "%%~a" "%%~b.txt" ) set /a "N+=1" ) goto :eof Sidenote: I echo...
by penpen
15 Jan 2021 16:48
Forum: DOS Batch Forum
Topic: Risk level validation
Replies: 4
Views: 144

Re: Risk level validation

Ad OP: Depending how you started your batch and if its name or its path contains spaces, the variable %~f0 might not neccessarily be correct. The only solution for that (special case) is to first call a function(-label) and use %~f0 from within that function. The way you delete all files also does m...
by penpen
05 Jan 2021 19:20
Forum: DOS Batch Forum
Topic: jTimestamp.bat date/time utility v2.1 - Replacement for getTimestamp.bat
Replies: 26
Views: 18299

Re: jTimestamp.bat date/time utility v2.1 - Replacement for getTimestamp.bat

ok.. this is why I also asked if there was a way to adjust it. Can we change wk 01 to be the first MONDAY? I like to add, that whatever day you choose, you run into the same issue (just with another day and in different years): If the 12/31/yyyy happens to be a MONDAY, than a script that defines it...
by penpen
05 Jan 2021 18:49
Forum: DOS Batch Forum
Topic: Equivalent 9XDos code to NT Find bat/cmd path %~dp0
Replies: 12
Views: 738

Re: Equivalent 9XDos code to NT Find bat/cmd path %~dp0

not sure how you do this Simply open a command prompt and type "set" (without doublequotes) and hit <ENTER>. Then check, if a an environment variable named "TMP" is there, contains a path name to a folder and then check if that folder exists and if you can create, edit and delete files in that fold...
by penpen
31 Dec 2020 17:55
Forum: DOS Batch Forum
Topic: Equivalent 9XDos code to NT Find bat/cmd path %~dp0
Replies: 12
Views: 738

Re: Equivalent 9XDos code to NT Find bat/cmd path %~dp0

I made two changes, that might help in some circumstances (in case command.com doesn't use current work directory - for whatever reasons; and in case of a possible write protection in the current directory). You should check, if the environment variable TMP is initialized correctly (to a path with r...
by penpen
30 Dec 2020 07:48
Forum: DOS Batch Forum
Topic: Equivalent 9XDos code to NT Find bat/cmd path %~dp0
Replies: 12
Views: 738

Re: Equivalent 9XDos code to NT Find bat/cmd path %~dp0

I have tried your TEST.BAT file as per your script code but it printed on screen - Bad Command or file name (on the next line it states) dir= I missed a "goto :eof" in the above code. I added and tested the result on win98SE, so that code should work now. could you give an outline of what the scrip...
by penpen
28 Dec 2020 10:54
Forum: DOS Batch Forum
Topic: jTimestamp.bat date/time utility v2.1 - Replacement for getTimestamp.bat
Replies: 26
Views: 18299

Re: jTimestamp.bat date/time utility v2.1 - Replacement for getTimestamp.bat

The above script uses ISO 8601, which defines the week 01 as that week which contains the first Thursday in January.
Therefore it is correct to return 53 for the week of 12/28/20, because this weeks Thursday is on 12/31/2020.


penpen
by penpen
28 Dec 2020 10:41
Forum: DOS Batch Forum
Topic: Equivalent 9XDos code to NT Find bat/cmd path %~dp0
Replies: 12
Views: 738

Re: Equivalent 9XDos code to NT Find bat/cmd path %~dp0

On older command environments, you typically either have to use debug.exe, qbasic.exe or you have to make an own temporary batch script to perform your tasks. The command line parameter "%0" won't always give you the path. It only contains the first token (~= meaningfull part) string used to execute...
by penpen
10 Dec 2020 01:09
Forum: DOS Batch Forum
Topic: On "color" command and errorlevel
Replies: 8
Views: 1024

Re: On "color" command and errorlevel

This might work for both .bat and .cmd (if you don't need any command line arguments for your batch): @echo off setlocal enableExtensions disableDelayedExpansion if "%~1" == "" call :init goto %~1 :eof :init %ComSpec% /k ""%~f0" ":main" & exit" goto :eof :main color 00 echo(%errorlevel% color echo(%...
by penpen
07 Dec 2020 08:26
Forum: DOS Batch Forum
Topic: On "color" command and errorlevel
Replies: 8
Views: 1024

Re: On "color" command and errorlevel

I actually can't test that, but isn't the set command suppose to do that, if you are using .cmd-files?

Code: Select all

@echo off
color 00
echo(%errorlevel%
set "unused="
echo(%errorlevel%
pause
goto :eof
penpen
by penpen
27 Nov 2020 18:32
Forum: DOS Batch Forum
Topic: Error level IF/THEN
Replies: 2
Views: 821

Re: Error level IF/THEN

The batch command line interpreter processes one line after another. So if it reaches your first errorlevel-based message, it simply proceeeds by processing the empty line after that, then the line with the :error-label and then the second errorlevel-based message.


penpen