Search found 1879 matches

by Aacini
12 May 2024 15:40
Forum: DOS Batch Forum
Topic: printf.exe: Arithmetic and Programming
Replies: 23
Views: 53179

Re: printf.exe: Arithmetic and Programming

A new release of printf.exe application is here! The new printf.exe version 2.55 adds some new features: A couple small bugs were fixed A new set of very efficient FPU-only operations were added CURS new operation to control the cursor was added FMT{:r option to show text in color was added Besides,...
by Aacini
03 Mar 2024 12:39
Forum: DOS Batch Forum
Topic: How to compare 2 modified file timestamps?
Replies: 6
Views: 2554

Re: How to compare 2 modified file timestamps?

Do you want to get the timestamps of two files and compare them, OR you just want to know which file is the last modified one? @echo off setlocal EnableDelayedExpansion set "files=aaaa.dat;bbbb.dat" set "older=" for /F "delims=" %%a in ('dir *.dat /O:-D') do ( if not defined older ( if "!files:%%a=!...
by Aacini
26 Feb 2024 18:07
Forum: DOS Batch Forum
Topic: How to read a txt file to sort out the string then output to a folder with some txt files
Replies: 9
Views: 2862

Re: How to read a txt file to sort out the string then output to a folder with some txt files

Try this: @echo off setlocal EnableDelayedExpansion set "folder=" for /F "delims=\" %%a in ('findstr "_ ." source.txt') do ( set "line=%%a" if not defined folder ( set "folder=!line:~-6!" md "!folder!" cd "!folder!" ) else if "!line:~0,1!" equ "T" ( set "file=!line!.txt" ) else ( >> "!file!" echo !l...
by Aacini
10 Feb 2024 20:05
Forum: DOS Batch Forum
Topic: Macro for Dummies
Replies: 16
Views: 11338

Re: Macro for Dummies

Some time ago I wrote my own explanation about how a macro with parameters works. You can read it here . Later, I wrote a large macro called SET/S that can replace a substring in a variable, and then the huge SET/A macro that expand function calls in a "set /A" expression. Both macros are at this th...
by Aacini
02 Feb 2024 00:32
Forum: DOS Batch Forum
Topic: Extract missing record
Replies: 6
Views: 5131

Re: Extract missing record

The solution of this problem have a subtle trick! :shock: :wink: I think this is the fastest method to solve this problem: @echo off setlocal EnableDelayedExpansion echo Results missing X1 record: set "last=" (for %%f in (*.pdf) do ( for /F "tokens=1-4 delims=_." %%a in ("%%f") do ( if not defined l...
by Aacini
04 Jan 2024 17:02
Forum: DOS Batch Forum
Topic: Batch File To Change Date Format In Filename
Replies: 7
Views: 8311

Re: Batch File To Change Date Format In Filename

. . . . . Always good to have a testing strategy. You may want to consider understanding the code you are using before using it. The reason the code you used screws up YYYY.MM.DD files is because it matches any files that end in the ##.##.##.pdf. That will match YYYY.MM.DD.pdf. You could pipe to an...
by Aacini
04 Jan 2024 13:51
Forum: DOS Batch Forum
Topic: Batch File To Change Date Format In Filename
Replies: 7
Views: 8311

Re: Batch File To Change Date Format In Filename

Try this: @echo off setlocal EnableDelayedExpansion for /F "delims=" %%a in ('dir /A:-D /B *.pdf') do ( set "name=%%a" for %%b in (%%a) do ( set "head=!name: %%b=!" for /F "tokens=1-3 delims=." %%x in ("%%b") do set "M=%%x" & set "D=%%y" & set "Y=%%z" ) if "!M:~2!" equ "" ( ECHO ren "%%a" "!head! 20...
by Aacini
18 Dec 2023 19:16
Forum: DOS Batch Forum
Topic: if statement or if satement
Replies: 4
Views: 6611

Re: if statement or if satement

Your code is wrong, not because the way of write that condition, but because the logic of such a condition. There are 3 possible results: The value of RDL_TYPE_NAME is equal to !RDL_TYPE_NAME:KIA=!, so is NOT equal to !RDL_TYPE_NAME:TKI=! and hence the IF is executed. The value of RDL_TYPE_NAME is e...
by Aacini
17 Dec 2023 11:45
Forum: DOS Batch Forum
Topic: Batch file to delete .inf files from a ADMIN CMDprompt.
Replies: 7
Views: 11008

Re: Batch file to delete .inf files from a ADMIN CMDprompt.

In the code of this answer : Change @echo %%b by set "driver=%%b" Insert pnputil.exe -f -d %driver% at end Ops! This don't works because the pipe! Modify the core code in this way: pnputil -e > test.txt findstr /R /C:".*!\n!.*!\n!.*!\n!.*%search%" test.txt > test2.txt for /F "tokens=2 delims=:" %%a ...
by Aacini
20 Nov 2023 00:55
Forum: DOS Batch Forum
Topic: Open a random bookmark from a datafile
Replies: 1
Views: 14007

Re: Open a random bookmark from a datafile

Mmm... Practically every line in this code have some type of error or bad construction... However, have not much sense to explain to you these problems because you have NOT wrote the code! I think this code do what you want: @echo off setlocal EnableDelayedExpansion set "file_path=C:\mydrive\bookmar...
by Aacini
18 Nov 2023 12:07
Forum: DOS Batch Forum
Topic: Timeout with GUI adjustments breaks its design after first second passes
Replies: 16
Views: 65163

Re: Timeout with GUI adjustments breaks its design after first second passes

Why you didn't tested my solution as I wrote it (more than one month ago)?

The last code you tested have duplicated the line # 45 and inserted an additional line # 48: del spacesFile.txt that is the cause that your code (not the mine!) don't works...

Antonio
by Aacini
14 Nov 2023 20:34
Forum: DOS Batch Forum
Topic: [Solved] Move file to incremental subfolder based on file name prefix
Replies: 3
Views: 15552

Re: Move file to incremental subfolder based on file name prefix

I think this works: @echo off setlocal EnableDelayedExpansion cd /D X:\PROJECT set "number=0" for %%a in (*.xml) do ( set "file=%%a" set "num=!file:~5,1!" if !num! neq !number! ( set /A "number=num, count=1" ) else ( set /A "count+=1" ECHO move "!file!" !count! ) ) Output: move "FIL005_2023111011344...
by Aacini
13 Nov 2023 07:06
Forum: DOS Batch Forum
Topic: [Solved] Need help to convert single line xml file to sequential line
Replies: 7
Views: 22995

Re: Need help to convert single line xml file to sequential line

Ok. This new code correctly works with the 262 KB size file. My first attempt fails because I assumed that no value could have a space! @echo off setlocal EnableDelayedExpansion set "n=0" set "last=" call :processLine < data.xml > output.xml goto :EOF :processLine set /P "line=" set "line=!last!!lin...
by Aacini
13 Nov 2023 05:41
Forum: DOS Batch Forum
Topic: [Solved] Need help to convert single line xml file to sequential line
Replies: 7
Views: 22995

Re: Need help to convert single line xml file to sequential line

The very first post in this site is How to get help for a batch script - quickly! , so surely you should saw it... Did you read it already? In such a post, there are these phrases: Batch files are often specific to your task because your filepaths, text, filenames and data are often used to write co...
by Aacini
11 Nov 2023 12:59
Forum: DOS Batch Forum
Topic: [Solved] Need help to convert single line xml file to sequential line
Replies: 7
Views: 22995

Re: Need help to convert single line xml file to sequential line

This works:

Code: Select all

@echo off
setlocal EnableDelayedExpansion

for /F "tokens=2* delims=>" %%a in (data.xml) do set "line=%%b"
set "next="
(for /F %%a in (^"!line:^>^<^=^>^
% Do NOT remove this line %
^<!^") do (
   if defined next echo !next!
   set "next=%%a"
)) > output.xml
Antonio