Search found 1668 matches

by Aacini
05 Oct 2020 04:41
Forum: DOS Batch Forum
Topic: [How-To] Calculate the date of Easter Sunday, for both the Gregorian and the Julian (Orthodox) Calendar
Replies: 2
Views: 486

Re: [How-To] Calculate the date of Easter Sunday, for both the Gregorian and the Julian (Orthodox) Calendar

At the end of this post I posted some time ago this subroutine that calculate the Easter Sunday based on integer arithmetic: :EasterSunday year rem Calculate the date of Christian Easter Sunday of any given year rem Antonio Perez Ayala set /A A=%1%%19, B=%1/100, C=%1%%100, D=B/4, E=B%%4, F=(B+8)/25,...
by Aacini
10 Sep 2020 20:02
Forum: DOS Batch Forum
Topic: A problem with symlink script
Replies: 6
Views: 743

Re: A problem with symlink script

I think you should start indicating that your "symlink script" is really a Batch-file script (specifically, one called "Symlink-Creator.bat") The problem with special Batch-file characters (like ! % & < > | ) is very well known... I suggest you to list the problematic file names and post the Batch-f...
by Aacini
03 Sep 2020 12:57
Forum: DOS Batch Forum
Topic: Copy, duplicate, rename...all that works, but the valuecheck is missing
Replies: 8
Views: 939

Re: Copy, duplicate, rename...all that works, but the valuecheck is missing

Sorry. I will not read any message that have the full text posted in colors and/or bold text with no reason...

Antonio
by Aacini
12 Aug 2020 09:08
Forum: DOS Batch Forum
Topic: Letter used in a variable.
Replies: 15
Views: 1851

Re: Letter used in a variable.

Mmmm... You entirely changed my code... Why you did that? In my answer I said that "the user enter just one letter selected from a well defined letters set" and put the letters "ABCDEF" as an example. Do you really want that the user can enter any letter from "A" to "Z"? Wouldn't be better to restri...
by Aacini
12 Aug 2020 05:39
Forum: DOS Batch Forum
Topic: Letter used in a variable.
Replies: 15
Views: 1851

Re: Letter used in a variable.

I think this is simpler: set "drives= ABCDEF" choice /C %drives% /N /M ">Please enter the drive letter: " set "drive=!drives:~%errorlevel%,1!" rem Check the drive here... This avoids all SET /P related problems and force the user to enter just one letter selected from a well defined letters set. Ant...
by Aacini
12 Aug 2020 05:27
Forum: DOS Batch Forum
Topic: Performance Issues with Code
Replies: 22
Views: 2157

Re: Performance Issues with Code

Which ShadowThief's solution is faster than which Antonio's solution? I wrote two solutions. The main loop in the second one is this: FOR /F "skip=1 USEBACKQ tokens=2 delims=|" %%a in ("test.txt") DO set /A "zBits|=m%%~a" It is hard to me to belive that such a loop is slower than this one: FOR /F "...
by Aacini
10 Aug 2020 13:08
Forum: DOS Batch Forum
Topic: Advanced Batch features via auxiliary .exe programs
Replies: 74
Views: 89090

Re: Advanced Batch features via auxiliary .exe programs

Thanks Steffen. Could you post it here in a .zip file?

Antonio
by Aacini
10 Aug 2020 11:36
Forum: DOS Batch Forum
Topic: Advanced Batch features via auxiliary .exe programs
Replies: 74
Views: 89090

Re: Advanced Batch features via auxiliary .exe programs

It seems there are two versions of CursorPos.exe! I found this new Help file: NEW: CursorPos version 1.2 This version includes two modifications: - When the cursor is moved, the value returned is previous cursor position. - If coordinates have this form: -cols +0 and the resulting column is negative...
by Aacini
10 Aug 2020 09:21
Forum: DOS Batch Forum
Topic: Only accept a numeric number.
Replies: 20
Views: 2273

Re: Only accept a numeric number.

The problem with using Set /P is that your end user can enter nothing at all or anything they like. For this reason you should not use Set /P at all... In my implementation , the user can enter a correct answer ONLY. If press ENTER at beginning, it is ignored. If press any key other than a digit bet...
by Aacini
05 Aug 2020 10:34
Forum: DOS Batch Forum
Topic: Performance Issues with Code
Replies: 22
Views: 2157

Re: Performance Issues with Code

Inspired by @Aacini's solution, some pseudo-code as I dont have the time and experience to convert this to proper code: Instead of month n=1..12, set month= 2^^n -1 (1.. 4095) set /a min=4095, max=0 For loop: set /a min="min & month", max="max | month" After the for-loop, convert 2^^n - 1 back to n...
by Aacini
04 Aug 2020 14:41
Forum: DOS Batch Forum
Topic: Performance Issues with Code
Replies: 22
Views: 2157

Re: Performance Issues with Code

Perhaps this would run a little faster... @echo off setlocal EnableDelayedExpansion rem Empty environment ( for /F "delims==" %%a in ('set') do set "%%a=" set "ComSpec=%ComSpec%" ) set /A "i=0, j=100" for %%a in (January February March April May June July August September October November December) ...
by Aacini
02 Aug 2020 12:36
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 1647

Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

This "strange" behavior of FOR parameters was previously discussed here (and in a nested link there): "The "global within a FOR context" design can lead to some nasty surprises. You might write a subroutine with a FOR loop that echos text with a percent literal. The routine works perfectly fine. The...
by Aacini
31 Jul 2020 23:17
Forum: DOS Batch Forum
Topic: Get line with highest numerical string
Replies: 12
Views: 3733

Re: Get line with highest numerical string

I think this do the trick: @echo off setlocal EnableDelayedExpansion set lastNum=0 for /F "delims=" %%a in ('findstr "outbox/logs/.*[0-9]\.log" test.txt') do ( set "a=%%~Na" for %%b in ("!a:_=.!") do set "num=%%~Xb" if !num:~1! gtr !lastNum! set "lastNum=!num:~1!" & set "lastLine=%%a" ) echo %lastLi...
by Aacini
31 Jul 2020 02:50
Forum: DOS Batch Forum
Topic: Only accept a numeric number.
Replies: 20
Views: 2273

Re: Only accept a numeric number.

IMHO, "only accept a number between 1 and 12" is something entirely different to "accept any string and check if it is a number between 1 and 12. If not, repeat the input" . The code below do the first thing: @echo off setlocal EnableDelayedExpansion rem Initialize variables for /F %%a in ('copy /Z ...
by Aacini
31 Jul 2020 02:08
Forum: DOS Batch Forum
Topic: JREPL: Cutting of a string after the n-th occurrence of specific character?
Replies: 17
Views: 2182

Re: JREPL: Cutting of a string after the n-th occurrence of specific character?

The irrelevant string preceding the directory path is cancelled if you use the /B switch in DIR command, as I did in my first answer. Didn't you saw it? Mmmm... I am afraid I don't understand what exactly the problem is... However, if you have these directories in the disk: C:\Users\Guy C:\Users\Guy...