Search found 1920 matches
- 02 Feb 2024 00:32
- Forum: DOS Batch Forum
- Topic: Extract missing record
- Replies: 6
- Views: 15658
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...
- 04 Jan 2024 17:02
- Forum: DOS Batch Forum
- Topic: Batch File To Change Date Format In Filename
- Replies: 7
- Views: 21595
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...
- 04 Jan 2024 13:51
- Forum: DOS Batch Forum
- Topic: Batch File To Change Date Format In Filename
- Replies: 7
- Views: 21595
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...
- 18 Dec 2023 19:16
- Forum: DOS Batch Forum
- Topic: if statement or if satement
- Replies: 4
- Views: 15421
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...
- 17 Dec 2023 11:45
- Forum: DOS Batch Forum
- Topic: Batch file to delete .inf files from a ADMIN CMDprompt.
- Replies: 7
- Views: 20499
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 ...
- 20 Nov 2023 00:55
- Forum: DOS Batch Forum
- Topic: Open a random bookmark from a datafile
- Replies: 1
- Views: 17489
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...
- 18 Nov 2023 12:07
- Forum: DOS Batch Forum
- Topic: Timeout with GUI adjustments breaks its design after first second passes
- Replies: 16
- Views: 86904
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
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
- 14 Nov 2023 20:34
- Forum: DOS Batch Forum
- Topic: [Solved] Move file to incremental subfolder based on file name prefix
- Replies: 3
- Views: 20539
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...
- 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: 31255
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...
- 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: 31255
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...
- 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: 31255
Re: Need help to convert single line xml file to sequential line
This works:
Antonio
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
- 22 Oct 2023 20:28
- Forum: DOS Batch Forum
- Topic: printf.exe: Arithmetic and Programming
- Replies: 31
- Views: 179456
Re: printf.exe: Arithmetic and Programming
Just download zip file, extract printf.exe and run it: :\Users\user>\utils\printf.exe printf.exe Version 1.0 Copyright (C) 2016-2020, Antonio Perez Ayala 'printfHelp.bat' is not recognized as an internal or external command, operable program or batch file. I am afraid the description of your proble...
- 20 Oct 2023 17:43
- Forum: DOS Batch Forum
- Topic: Is it worth learning Powershell?
- Replies: 10
- Views: 56883
Re: Is it worth learning Powershell?
First point: PowerShell is more powerful than Batch files. There are tasks that can not be completed in a Batch file, but in PowerShell. However, such tasks are rare. The vast majority of daily management tasks can be completed with a Batch file. That said, IMHO PowerShell is difficult to learn and ...
- 16 Oct 2023 12:59
- Forum: DOS Batch Forum
- Topic: Timeout with GUI adjustments breaks its design after first second passes
- Replies: 16
- Views: 86904
Re: Timeout with GUI adjustments breaks its design after first second passes
Are you sure you copied the Batch file as it is? Antonio Yes, I am sure... Mmmm... The script I posted have 47 lines. These are the last ones: 38::CreateSpacesFile numOfSpaces 39:setlocal EnableDelayedExpansion 40:set "spcs=" 41:for /L %%i in (1,1,%1) do set "spcs=!spcs! " 42:set /P ^"=X^ 43:% Do n...
- 14 Oct 2023 12:07
- Forum: DOS Batch Forum
- Topic: Timeout with GUI adjustments breaks its design after first second passes
- Replies: 16
- Views: 86904
Re: Timeout with GUI adjustments breaks its design after first second passes
It produces Info about what the script will do Info Executing in: Info 3The 2The 1The The script has been executed Info [Press any key to close this CMD window] and leaves that spacesFile.txt file behnd It works perfectly here: #1 Info about what the script will do Executing in: 3 #2 Info about wha...