Search found 74 matches
- 25 Mar 2024 19:09
- Forum: DOS Batch Forum
- Topic: How to compare 2 modified file timestamps?
- Replies: 6
- Views: 12474
Re: How to compare 2 modified file timestamps?
V1.bat @echo off set "File1=D:\\Test\\1.txt" set "File2=D:\\Test\\2.txt" for /f "tokens=2 delims==" %%i in ('wmic DataFile where "Name='%File1%'" get LastModified /value ^| findstr "="') do ( for %%j in ("%%i") do ( set "ModiTime1=%%~j" ) ) for /f "tokens=2 delims==" %%i in ('wmic DataFile where "Na...
- 19 Jan 2024 23:07
- Forum: DOS Batch Forum
- Topic: How to copy a txt file into multiple txt files in a destination folder
- Replies: 3
- Views: 10006
Re: How to copy a txt file into multiple txt files in a destination folder
1.bat
Code: Select all
@echo off
set "OldFile=C:\Test\1.txt"
set "NewFolder=C:\Test\To"
for /f "delims=" %%i in ('dir /b /a-d "%NewFolder%\*.txt"') do (
>>"%NewFolder%\%%i" echo,
>>"%NewFolder%\%%i" type "%OldFile%"
)
- 04 Jan 2024 06:48
- Forum: DOS Batch Forum
- Topic: Batch File To Change Date Format In Filename
- Replies: 7
- Views: 16171
Re: Batch File To Change Date Format In Filename
1.bat @echo off cd /d "%~dp0" setlocal enabledelayedexpansion for /f "delims=" %%a in ('dir /b /a-d *.pdf ^| findstr /i /e "[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]\.pdf"') do ( for %%b in ("%%~na") do ( set "yyyy=20%%~xb" set "yyyy=!yyyy:.=!" for %%c in ("%%~nb") do ( set "dd=%%~xc" set "dd=!dd:.=!" set ...
- 31 Dec 2023 21:58
- Forum: DOS Batch Forum
- Topic: code in else statement not executing
- Replies: 4
- Views: 11140
Re: code in else statement not executing
2.bat @echo off setlocal EnableDelayedExpansion set "driverinf=magu.inf" set "readerId=USB\VID_076B&PID_5320\OKCM0021111090337566741524390121" pnputil /enum-devices /connected /drivers /class Printer | findstr /C:"%driverinf%" >nul if %errorlevel% equ 0 ( echo Printer Driver found.. ) else ( echo Pr...
- 31 Dec 2023 21:56
- Forum: DOS Batch Forum
- Topic: code in else statement not executing
- Replies: 4
- Views: 11140
Re: code in else statement not executing
1.bat @echo off set "driverinf=magu.inf" set "readerId=USB\VID_076B&PID_5320\OKCM0021111090337566741524390121" pnputil /enum-devices /connected /drivers /class Printer | findstr /C:"%driverinf%" >nul if %errorlevel% equ 0 ( echo Printer Driver found.. ) else ( echo Printer Driver not found..Looking ...
- 22 Dec 2023 08:45
- Forum: DOS Batch Forum
- Topic: Why for loop wmic get processid return an extra invalid value?
- Replies: 3
- Views: 10565
Re: Why for loop wmic get processid return an extra invalid value?
Code: Select all
@echo off
for /f "tokens=2 delims==" %%a in ('wmic process where "name='cmd.exe' and commandline like '%%%~n0%%'" get processid /value 2^>nul ^| find "="') do (
call set "MyStr=%%%%a"
)
echo --%MyStr%--
pause
- 20 Dec 2023 03:30
- Forum: DOS Batch Forum
- Topic: Batch file to replace - with . in file name
- Replies: 6
- Views: 24125
Re: Batch file to replace - with . in file name
Code: Select all
@echo off
cd /d "%~dp0"
for /f "delims=" %%i in ('dir /b /s /a-d *-*.pdf') do (
set "OldFile=%%i"
set "OldName=%%~nxi"
setlocal enabledelayedexpansion
set NewName=!OldName:- Deposit=TALLY!
set NewName=!NewName:-=.!
ren "!OldFile!" "!NewName!"
endlocal
)
pause
- 20 Dec 2023 03:30
- Forum: DOS Batch Forum
- Topic: Replace Word In Filename With Another Word
- Replies: 3
- Views: 10790
Re: Replace Word In Filename With Another Word
Code: Select all
@echo off
cd /d "%~dp0"
for /f "delims=" %%i in ('dir /b /s /a-d *-*.pdf') do (
set "OldFile=%%i"
set "OldName=%%~nxi"
setlocal enabledelayedexpansion
set NewName=!OldName:- Deposit=TALLY!
set NewName=!NewName:-=.!
ren "!OldFile!" "!NewName!"
endlocal
)
pause
- 18 Dec 2023 19:55
- Forum: DOS Batch Forum
- Topic: if statement or if satement
- Replies: 4
- Views: 12443
Re: if statement or if satement
if defined RDL_TYPE_NAME ( call :UpCase RDL_TYPE_NAME if not "!RDL_TYPE_NAME!"=="!RDL_TYPE_NAME:KIA=!" ( echo Skipping !RDL_TYPE_NAME! set RDL_TYPE_NAME= goto :endOfProcessing ) else if not "!RDL_TYPE_NAME!"=="!RDL_TYPE_NAME:TKI=!" ( echo Skipping !RDL_TYPE_NAME! set RDL_TYPE_NAME= goto :endOfProce...
- 15 Dec 2023 21:38
- Forum: DOS Batch Forum
- Topic: How to make an underscore variable "-----" with the length of the argument variable?
- Replies: 5
- Views: 14041
Re: How to make an underscore variable "-----" with the length of the argument variable?
2.bat
Code: Select all
@echo off
call :MakeUnderscore "Script Name"
echo,
echo Hello World
pause
exit /b
:MakeUnderscore
echo,%~1
for /f "skip=1 delims=:" %%a in ('^(echo "%~1"^&echo.^)^|findstr /o ".*"') do (
set /a StrLen=%%a-5
)
for /l %%i in (1,1,%StrLen%) do (
set /p =-<nul
)
- 15 Dec 2023 21:33
- Forum: DOS Batch Forum
- Topic: How to make an underscore variable "-----" with the length of the argument variable?
- Replies: 5
- Views: 14041
Re: How to make an underscore variable "-----" with the length of the argument variable?
1.bat
Code: Select all
@echo off
echo Script Name
call :MakeUnderscore 11
echo,
echo Hello World
pause
exit /b
:MakeUnderscore
for /l %%i in (1,1,%1) do (
set /p =-<nul
)
- 04 Dec 2023 20:41
- Forum: DOS Batch Forum
- Topic: Batch file to replace - with . in file name
- Replies: 6
- Views: 24125
Re: Batch file to replace - with . in file name
CurrentAndSubFolder.bat
Code: Select all
@echo off
cd /d "%~dp0"
for /f "delims=" %%i in ('dir /b /s /a-d *-*.pdf') do (
set "OldFile=%%i"
set "OldName=%%~nxi"
setlocal enabledelayedexpansion
set NewName=!OldName:-=.!
ren "!OldFile!" "!NewName!"
endlocal
)
- 04 Dec 2023 20:41
- Forum: DOS Batch Forum
- Topic: Batch file to replace - with . in file name
- Replies: 6
- Views: 24125
Re: Batch file to replace - with . in file name
CurrentFolderOnly.bat
Code: Select all
@echo off
cd /d "%~dp0"
for /f "delims=" %%i in ('dir /b /a-d *-*.pdf') do (
set "OldName=%%i"
setlocal enabledelayedexpansion
set NewName=!OldName:-=.!
ren "!OldName!" "!NewName!"
endlocal
)
- 03 Dec 2023 19:45
- Forum: DOS Batch Forum
- Topic: Copy cmd window and write to .txt
- Replies: 2
- Views: 22300
Re: Copy cmd window and write to .txt
You may want to try mtee.exe
https://github.com/ritchielawrence/mtee
https://github.com/ritchielawrence/mtee
- 30 Nov 2023 19:18
- Forum: DOS Batch Forum
- Topic: dism.exe isn't running.
- Replies: 6
- Views: 29583
Re: dism.exe isn't running.
-ot folder ---> -ot file
https://helgeklein.com/setacl/documenta ... etacl-exe/
Type of object:
https://helgeklein.com/setacl/documenta ... etacl-exe/
Type of object:
- file Directory/file
reg Registry key
srv Service
prn Printer
shr Network share
wmi WMI object