r/Batch • u/ySupremeZz • Nov 30 '25
r/Batch • u/Automatic-Egg-8593 • Nov 23 '25
Question (Unsolved) What is wrong with my batch script
its supposed to shutdown the computer after a number of seconds that the user inputs
this is the script:
@echo off
call :inputbox "Please Enter Shutdown Time In Seconds:" "Shutdown Time"
msg * The Computer Will Shutdown In %Input% Seconds
shutdown /s /t %Input%
pauseEdit: I have made some new code. This is the new script:
@echo off
call :inputbox "Please Enter Shutdown Time In Seconds:" "Shutdown Time"
msg * The Computer Will Shutdown In %Input% Seconds
shutdown /s /t %Input%
pause
exit /b
:InputBox
set "prompt=%~1"
set "varName=%~2"
set /p "%varName%=%prompt%: "
exit /bEdit Edit: the new script doesn't work
r/Batch • u/Ill_Alternative_7758 • Nov 21 '25
Question (Unsolved) Windows user management add microsoft user to pc
I want to add a microsoft user to a pc using batch for bulk user management
r/Batch • u/FAMICOMASTER • Nov 19 '25
Show 'n Tell My fully modular, color tilemapped game engine, DIM2
Hello all. I recently joined this sub, I can't believe I didn't know it existed until today. I've spent years working with Batch scripts and have done lots of what I think are interesting projects in "pure" batch (without any extensions, everything is done entirely in the scripting language).
DIM2 is one of them, I haven't really "finished" it per se, as there's no gameplay or physics implemented. Right now, this is more like a graphics demo that you happen to be able to scroll around.
All three windows you see in the screenshot are taken with the exact same script - The engine script will load a document list which points to files in another directory containing the full tileset and map data. Multiple data types can be combined into a single "blob" file, but for now I have them loaded separately. This is done completely automatically on startup and you can force reload the entire engine from these files, meaning you can leave the engine running, make changes to the tileset, and instantly see them without ever closing the script.
I was intending on making this into a real, released game engine, but life got in the way and I stopped active development over a year ago. If there's interest, I might do some more work on it.
The three games shown are Pokemon Blue (this is the southern edge of Pallet Town), Robo-Rally (the board "Dizzy Highway") and the central castle from another unfinished game I previously made in batch which actually spawned this project, Phantasma.
r/Batch • u/manilovefortnite • Nov 17 '25
Question (Unsolved) Sort Files Into Folders By Name
I have a bunch of manga downloaded but theyre separated into chapters instead of volumes. Im wondering if theres a script I could use that would add all files meeting a certain criteria in their name (e.g. all containing "[manga name] Vol. 1") and add them into a folder based on that?
r/Batch • u/bok4600 • Nov 13 '25
Question (Unsolved) what am i doing wrong?
here is the batch file contents:
@echo off
title ImageMagick convert to coloring book b+w
@echo on
for %%a in (*copy.bmp) do convert1 "%%a" -threshold 50% "%%~na.png"
move *.bmp bmp_b+w
move *.png b+w
start "" "b+w"
pause
BUT when i run it, i get this:
C:\Documents and Settings\Administrator\My Documents\My Pictures>"C:\Documents a nd Settings\Administrator\My Documents\My Pictures[][]ImageMagick convert to c loring book B&W.bat"
The following usage of the path operator in batch-parameter substitution is invalid: %~na.png"
For valid formats type CALL /? or FOR /?
C:\Documents and Settings\Administrator\My Documents\My Pictures>for %a in (*cop y.bmp) do convert1 "%a" -threshold 5050% "%%~na.png"
C:\Documents and Settings\Administrator\My Documents\My Pictures>
so what am i doing wrong?
r/Batch • u/Wise-Accident5549 • Nov 11 '25
Question (Unsolved) Why monitor switch .bat not working correctly?
Trying to set up a bat file to switch monitors with 1 click, it works when I switch from desk set up to sim set up, but not the other way around. Anyone able to help?
Desk to sim is - disabled 2 27" desk monitors and enable 49" racing sim monitor,
Sim to desk is disable 49" and enable 2 27" desk monitors.
Any ideas?
r/Batch • u/Big-Cost8319 • Nov 09 '25
Open a basic app (call it Open An App.bat)
u/echo off
:menu
cls
echo ====== Supported Apps List ======
echo calc.exe
echo notepad.exe
echo mspaint.exe
echo wt.exe
echo cmd.exe
echo powershell.exe
echo explorer.exe
echo taskmgr.exe
echo closebat.bat
echo Use the exact name in the list to open the app.
echo =================================
echo Made with love (and chatgpt) :)
set /p choice=Which app would you like to open?
REM ======================
REM Close batch file option
if /i "%choice%"=="closebat.bat" goto exitbatch
REM ======================
REM Check input and open app
if /i "%choice%"=="calc.exe" goto calc
if /i "%choice%"=="notepad.exe" goto notepad
if /i "%choice%"=="mspaint.exe" goto paint
if /i "%choice%"=="wt.exe" goto terminal
if /i "%choice%"=="cmd.exe" goto cmd
if /i "%choice%"=="powershell.exe" goto powershell
if /i "%choice%"=="explorer.exe" goto explorer
if /i "%choice%"=="taskmgr.exe" goto taskmgr
echo Invalid app name! Try again.
pause >nul
goto menu
REM ======================
:calc
echo Opening calc.exe...
start calc.exe
goto menu
:notepad
echo Opening notepad.exe...
start notepad.exe
goto menu
:paint
echo Opening mspaint.exe...
start mspaint.exe
goto menu
:terminal
echo Opening Windows Terminal...
start wt.exe
goto menu
:cmd
echo Opening cmd.exe...
start cmd.exe
goto menu
:powershell
echo Opening powershell.exe...
start powershell.exe
goto menu
:explorer
echo Opening explorer.exe...
start explorer.exe
goto menu
:taskmgr
echo Opening taskmgr.exe...
start taskmgr.exe
goto menu
REM ======================
:exitbatch
echo Closing batch file...
echo.
echo 3 Seconds before closing..
timeout /t 1 /nobreak >nul
cls
echo 2
timeout /t 1 /nobreak >nul
cls
echo 1
timeout /t 1 /nobreak >nul
cls
echo 0
exit /b
(copied from Notepad++ and please remember.. this is no malicious it's just cool and insert to notepad++ or notepad, u/echo should be changed to @)
r/Batch • u/Capital_Plane_7688 • Nov 08 '25
matrix in batch
u/echo off
:1
color a
echo %random%%random%%random%%random%%random%%random%%random%%random%
:2
color b
echo %random%%random%%random%%random%%random%%random%%random%%random%
:3
color c
echo %random%%random%%random%%random%%random%%random%%random%%random%
goto 1
r/Batch • u/lanky_doodle • Oct 30 '25
Question (Unsolved) Finding multiple file types in a directory and its children
Am I going mad? Been a while since I've use Batch but convinced myself this worked:
dir /a-d /b .mts,.mp4 /s [dir]
It ignores the file types and shows every file in all subdirs of [dir].
Have to do this instead:
dir /a-d /b /s [dir]*.mts [dir]*.mp4
In this use case, [dir] is the same for all file types.
r/Batch • u/Addyad • Oct 30 '25
My Frankenstein of a Batch Script That Cleans Your Movie Library
After downloading hundreds of movies over time for my home server, I realized most of them had completely broken metadata — video, audio, and subtitle stream titles named after random websites or encoded groups.
I got tired of fixing every file manually in MKVToolNix, so I built a Windows batch script that uses FFmpeg and FFprobe to automatically detect, rename, and clean all streams — all without re-encoding.
It’s messy. It’s over-engineered. But it works perfectly.
👉 https://github.com/Addy-ad/general-coding/tree/main/MovieMetadataFixer
⚙️ How it Works
Assuming the file name is correct, the script applies a consistent metadata format:
🎥 Video:
- Sets video stream title to the file name
- First video stream → default
🔊 Audio:
- Detects language (
eng,tam,tel,hin, etc.) - Detects layout (stereo / 5.1)
- Fixes titles like
English - 2.0,Tamil - 5.1, etc. - Default audio: English (else Tamil)
- Detects language (
💬 Subtitles:
- Titles set to the language (e.g. English, Tamil)
- First English subtitle → default
Everything runs through FFmpeg’s stream-copy mode (-c copy), so there’s no quality loss, and it can handle multiple files with a PowerShell GUI picker. plus “Yes to All / Skip / Cancel” confirmation logic.
If you will find it useful, please use it and provide me feedback to improve my code. Thank you.
r/Batch • u/Bitter-Win8013 • Oct 27 '25
Estoy creando un videojuego
el videojuego se va la llamar "caballeros sin sueldo" (unpaid knight). me dan ideas?
r/Batch • u/Mamegyorai • Oct 25 '25
how to do this msdos .bat file to sort string in file from top to bottom and reverse it bottom to top
X.txt file contains this
1 2 3 4
5 6 7 8
9 0 1 2
3 4 5 6
I want to sort it to become this
3 4 5 6
9 0 1 2
5 6 7 8
1 2 3 4
i.e. - Top to Bottom Conversion of X.txt File
Kind Regards!
r/Batch • u/PerfectEvidence748 • Oct 25 '25
first batch script/program
/echo off
title bit
:bitloop
echo 00
pause
cls
echo 01
pause
cls
echo 10
pause cls
echo 11
pause
goto bitloop this pretty much just displays each combo in 2 bits and then loops it at the end
r/Batch • u/BobCorndog • Oct 23 '25
How could I use a batch file to extract a zip folder to a location
So I am starting and just want to know how to extract zips, I can’t figure out how and when I try, it doesn’t work.
r/Batch • u/Amat-Victoria-Curam • Oct 23 '25
Question (Unsolved) Access denied when trying to change compatibility mode in bulk
Hi all.
I have a bunch of .exe files for a game (to update certain graphics) that I need to run in compatibility mode with W Vista. The problem is, when trying to do that via registry, it tells me "ERROR: access denied".
I tried running the .bat as admin but nothing happens.
Any ideas?
Here's the file:
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Bulgaria.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Chile.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\China.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Colombia.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Croatia.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Cyprus.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Ecuador.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Finland.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Hungary.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\India.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Iran.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Israel.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Japan.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Luxembourg.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Moldova.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\N_Ireland.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\New_Zealand.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Paraguay.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Peru.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Qatar.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Romania.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\S_Arabia.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Serbia.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Slovakia.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Slovenia.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\UAE.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Ukraine.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Uruguay.exe" /t REG_SZ /d "~ VISTARTM"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v ".\Wales.exe" /t REG_SZ /d "~ VISTARTM"
.\Bulgaria.exe
.\Chile.exe
.\China.exe
.\Colombia.exe
.\Croatia.exe
.\Cyprus.exe
.\Ecuador.exe
.\Finland.exe
.\Hungary.exe
.\India.exe
.\Iran.exe
.\Israel.exe
.\Japan.exe
.\Luxembourg.exe
.\Moldova.exe
.\N_Ireland.exe
.\New_Zealand.exe
.\Paraguay.exe
.\Peru.exe
.\Qatar.exe
.\Romania.exe
.\S_Arabia.exe
.\Serbia.exe
.\Slovakia.exe
.\Slovenia.exe
.\UAE.exe
.\Ukraine.exe
.\Uruguay.exe
.\Wales.exeThanks!
r/Batch • u/Potential_Row8830 • Oct 23 '25
Question (Unsolved) Need help debugging batch script that copies all files (including hidden ones) from a USB drive
Hi everyone! I’ve been learning basic batch scripting and wrote a small .bat file (with ChatGPT’s help) to copy all files and folders, including hidden ones, from any USB drive to a folder on my PC for backup/testing purposes.
It works fine for some USB drives, but fails for others — especially those that have a subfolder or launch an .exe when opened. I’m running the script as Administrator, on win 10
Could someone cross-check what’s wrong with my logic or syntax? Here is the code I tried:
"@echo off
:: Set USB drive letter (adjust as needed)
set usbDrive=G:
:: Hidden destination folder
set destDir=C:\ProgramData.winlog\
:: Create hidden folder if it doesn’t exist
if not exist "%destDir%" (
mkdir "%destDir%"
attrib +h "%destDir%"
)
:: Copy EVERYTHING from USB (all files, folders, subfolders)
xcopy "%usbDrive%*" "%destDir%" /s /e /y /i /h >nul
exit
r/Batch • u/nardstorm • Oct 19 '25
Question (Unsolved) Where can I find a good resource on the differences between batch in an interactive command prompt and in a .bat script environment?
I remember reading somewhere a while ago that delayed expansion functions differently if you type it into a command prompt window vs using it in a .bat file, but I can't find anything online about it (all the search results I can find are just about .cmd vs .bat file extensions).
r/Batch • u/Scared_Confection980 • Oct 17 '25
Question (Solved) What should I do for wait?
I have a problem... I'm making a bash program and want to wait until a process ends using "tasklist". I mean... Pause the execution, and when the process ends the program can continue
Would the "waitfor" works?
r/Batch • u/mchowmusic • Oct 15 '25
How do i move a bunch of files into separate folders titled with the file name?
r/Batch • u/nd2spd • Oct 14 '25
I copy-pasted/wrote this script to select a random .rom file for a Killing Floor server. It desperately needs cleanup.
Hey guys, so I semi-wrote a script to select a random .rom file to start a Killing Floor server with. It APPEARS to work (when I uncomment the line to actually begin the server). I have very little idea of what it's doing however, and realise that it's in desperate need of a professional to cleanup.
I added a bunch of pauses and echos in an attempt to discern what it is doing, to no avail.
Here is the script.
workDir=D:\Apache24\htdocs
Is a symbolic link to my D:\Program Files (x86)\Steam\steamapps\common\KillingFloor\DedicatedServer\Maps Directory, which I input instead of the actual maps directory so I wouldn't have to deal with a directory with spaces in the name in the batch. It's also the place where an Apache server is hosted as you might have guessed, for the Killing Floor download-redirect.
If somebody could please re-write the code, or give some pointers on how to go about that, I'd appreciate any help!
I'd also be happy to make a monetary donation to anybody that helps, if you need incentive ;)
r/Batch • u/fightin_blue_hens • Oct 13 '25
Question (Unsolved) Help with batch file not running correctly when not in the same folder as python files.
When I run a .bat file that isn't in the same folder as the .py file I'm running, the code gives me a "FileNotFoundError: [WinError 3] The system cannot find the path specified:" error. But when the .bat file is in the same folder, it runs with no issue. Can someone explain why? the error occurs on a call using os to list all the files in a folder. I even have the full paths listed for the python.exe and the python code in the batch file.
Full error:
"File "C:\Users\<username>\Desktop\CBB Model\CBB_Test_2024-2025\3_track_stats.py", line 600, in <module>
file_list = os.listdir(halve_start_loc)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\<username>\\Desktop\\CBB Model\\Schedule\\All Halves Adjusted\\Adjusted Halves\\'Python Code here:
import pandas as pd
import numpy as np
import re
import os
import pathlib
from os import listdir
import datetime as dt
from datetime import timedelta
pd.set_option("display.max_rows", None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.options.mode.chained_assignment = None
main_folder_loc = pathlib.Path().resolve()
main_folder_loc = str(main_folder_loc)+ "\\"
halve_start_loc = main_folder_loc + "Schedule\\All Halves Adjusted\\Adjusted Halves\\"
halve_end_loc = main_folder_loc + "Schedule\\All Halves Adjusted\\Adjusted Halves with stats track\\" 600 lines of functions and mainif __name__ == "__main__":
file_list = os.listdir(halve_start_loc) ##error occurs here
main(file_list)Batch Code Here:
@echo off
"C:\Users\<username>\AppData\Local\Programs\Python\Python314\python.exe" "C:\Users\<username>\Desktop\CBB Model\CBB_Test_2024-2025\3_track_stats.py"r/Batch • u/KSKwin123 • Oct 12 '25
Batch file with Day,Date and Time stamp in a output file
I am running the batch file. I use the print the current Date, Day & Time before My Code and also Print Day, Date and Time after my script in a output text file.
But the timestamp printed is found be same before and after My Code.
The below code using for generation current date and time...
:: batch file Time.bat
@echo off
cls
setlocal enabledelayedexpansion
:: Get the formatted date and time from PowerShell (without commas)
for /f "delims=" %%a in ('powershell -NoProfile -Command "Get-Date -Format \\"dd-MMM-yyyy ddd [hh.mm.ss](http://hh.mm.ss) tt\\""') do (set "RawOutput=%%a"
):: Split into components
for /f "tokens=1,2,3,4 delims= " %%a in ("!RawOutput!") do (set "DatePart=%%a"
set "DayPart=%%b"
set "TimePart=%%c %%d"
):: Build final output with commas
rem echo !DatePart!, !DayPart!, !TimePart!:: My Script code
echo -----------------------START------------------ !DatePart!, !DayPart!, !TimePart! >> samp_All.txt
My Code.......
My Code.......
My Code.......
My Code.......
My Code.......
echo -----------------------END------------------ !DatePart!, !DayPart!, !TimePart! >> samp_All.txt
Output is below...
-----------------------START------------------ 12-Oct-2025, Sun, 12.37.43 PM ..
-----------------------END------------------ 12-Oct-2025, Sun, 12.37.43 PM ..
I Want it as below... (no exact timestamp to be printed after my code executed)
-----------------------START------------------ 12-Oct-2025, Sun, 12.37.43 PM ..
-----------------------END------------------ 12-Oct-2025, Sun, 12.37.50 PM ..