Search found 1585 matches

by Aacini
20 Mar 2019 10:29
Forum: DOS Batch Forum
Topic: Generating consecutive dates
Replies: 1
Views: 60

Generating consecutive dates

In some Batch-file applications the generation of consecutive dates is needed. The usual way to solve this problem is converting the base date to a Julian Day Number, increment/decrement this number by one and then convert it back to date. Other suggested method is using other languages that nativel...
by Aacini
19 Mar 2019 16:24
Forum: DOS Batch Forum
Topic: Lag methodology
Replies: 5
Views: 132

Re: Lag methodology

I would like to present a simpler approach: @echo off setlocal EnableDelayedExpansion set /P "YYYYMMDD=Enter date in YYYYMMDD format: " set /P "days=Enter number of days: " set /A "DD=100+(D=YYYYMMDD%%100), YYYYMM=YYYYMMDD/100, MM=100+(M=YYYYMM%%100), YYYY=YYYYMM/100 for /L %%i in (1,1,%days%) do ( ...
by Aacini
14 Mar 2019 09:34
Forum: DOS Batch Forum
Topic: Is this possible to be done?
Replies: 2
Views: 74

Re: Is this possible to be done?

Code: Select all

@echo off
setlocal EnableDelayedExpansion

set "reply[0]=Down" & set "reply[1]=Live"

(for /L %%i in () do (
   ping nonsense.com >nul
   call echo %%reply[!errorlevel!]%%
) > logfile.txt
Antonio
by Aacini
12 Mar 2019 10:01
Forum: DOS Batch Forum
Topic: Setting a variable value to single whitespace
Replies: 6
Views: 120

Re: Setting a variable value to single whitespace

I am afraid you have a confusion here... In Batch files, a variable can be undefined , that is, it does not exists (like in set "var=" ), or it can contain any string, including a blank space (like in set "var= " ). In any case, the variable !expansion! replaces it by the variable value: nothing if ...
by Aacini
04 Mar 2019 09:14
Forum: DOS Batch Forum
Topic: Cardioid - Heart Curve
Replies: 6
Views: 187

Re: Cardoid - Heart Curve

Interesting! https://i.imgur.com/nRzf0qj.jpg @echo off setlocal EnableDelayedExpansion for /F %%a in ('echo prompt $E^| cmd') do set "ESC=%%a" set "_SIN=a-a*a/1920*a/312500+a*a/1920*a/15625*a/15625*a/2560000-a*a/1875*a/15360*a/15625*a/15625*a/16000*a/44800000" set "SIN=(a=((x) * 31416 / 180)%%62832,...
by Aacini
04 Mar 2019 08:50
Forum: DOS Batch Forum
Topic: Cardioid - Heart Curve
Replies: 6
Views: 187

Re: Cardoid - Heart Curve

Ops! You are using ANSI sequences to move the cursor... :(

This just works in Windows 10, or with an ANSI driver installed. :cry:

Antonio
by Aacini
01 Mar 2019 09:59
Forum: DOS Batch Forum
Topic: How to eliminate the spaces in a line in a text file
Replies: 9
Views: 233

Re: How to eliminate the spaces in a line in a text file

Simpler: @echo off setlocal EnableDelayedExpansion (for /F "delims=" %%a in (input.txt) do ( set "input=%%a" if "!input:~40!" equ "" ( echo(!input! ) else ( set "output=!input:~0,1!" if "!output!" neq " " set "output=" for %%b in (!input!) do set "output=!output!%%b " echo(!output:~0,-1! ) )) > outp...
by Aacini
28 Feb 2019 20:06
Forum: DOS Batch Forum
Topic: How to eliminate the spaces in a line in a text file
Replies: 9
Views: 233

Re: How to eliminate the spaces in a line in a text file

Several comments about your "question": Your example is incorrect. Line 1 is 78 chars, not < 40 I suppose that with "replace all the spaces with single space" you really want to say "replace all groups of adjacent spaces with single space". If so, then: Lines 4 and 5 in the output example are wrong,...
by Aacini
13 Feb 2019 09:38
Forum: DOS Batch Forum
Topic: Set Window Topmost (Powershell hybrids)
Replies: 4
Views: 186

Re: Set Window Topmost (Powershell hybrids)

You may precompile all DLL files and keep the class definitions open in a resident PowerShell code, so the posterior usage of the Windows API's is very fast. The technique is described at Read arrow keys and show color text in an efficient way.

Antonio
by Aacini
06 Feb 2019 05:38
Forum: DOS Batch Forum
Topic: Manage multiple databases services using batch script
Replies: 16
Views: 393

Re: Load multiple parameters from file

I tried this. It works. This is the _list.log file: word1 word2 word3 This is the par.bat Batch file: @echo off setlocal EnableDelayedExpansion set /a cnt=0 for /f %%G in (_list.log) do (set /a cnt+=1 & set "param!cnt!=%%G") set param echo %param1% This is the output: C:\Users\Antonio\Documents\test...
by Aacini
05 Feb 2019 11:20
Forum: DOS Batch Forum
Topic: Manage multiple databases services using batch script
Replies: 16
Views: 393

Re: Load multiple parameters from file

.... in other words:

Try to insert this line:

Code: Select all

echo %param1%
at end of par.bat :roll:

Antonio
by Aacini
31 Jan 2019 19:34
Forum: DOS Batch Forum
Topic: An easy set calculation
Replies: 2
Views: 176

Re: An easy set calculation

@echo off setlocal :loop set "num=" set /P "num=Enter integer number: " if not defined num goto :EOF set /A "div=num*80" echo %num% / 1.25 = %div:~0,-2%.%div:~-2% goto loop Example: Enter integer number: 10 10 / 1.25 = 8.00 Enter integer number: 100 100 / 1.25 = 80.00 Enter integer number: 1000 100...
by Aacini
27 Jan 2019 19:54
Forum: DOS Batch Forum
Topic: Check and identify Lin Files by contents
Replies: 4
Views: 146

Re: Check and identify Lin Files by contents

In your first post you said: "My need is to check contents of each file and to identify 100% duplicate files" . Now you changed the requirement to "i wish to check files of different sizes also to find if same text appears" . This is an entirely different problem... I strongly suggest you to read th...
by Aacini
27 Jan 2019 12:43
Forum: DOS Batch Forum
Topic: delete files in Folder with version-stamp
Replies: 4
Views: 224

Re: delete files in Folder with version-stamp

I am afraid I don't understand your requirement... Do you want to remove all files with the same string before the underscore, excepting the last one? If so, then you may try this solution: @echo off setlocal EnableDelayedExpansion set "group=" for /F "tokens=1* delims=_" %%a in ('dir /A-D /B *.pdf'...