Questions tagged [batch]
Batch processing is the execution of a set of commands or software programs without user intervention. A batch file is a text file containing a sequence of such commands or programs invocations. Please use the tag [batch-file] for that.
3,974
questions
1
vote
2
answers
1k
views
delete all subfolders using a batch file?
To delete all bin folders rooting from any subfolders from the current path, I have the following script, this is what I've tried (as far as my knowledge about batch script is):
setlocal ...
1
vote
2
answers
41
views
Searching audio extensions in a folder
I'm trying to check in a folder of audio files that the mp3, flac and wav extensions DO NOT EXIST. If none of the three exist, I send a message that there are no audio files in the folder.
I made a ...
1
vote
1
answer
3k
views
in batch For loop , echo %%i:~0,5% doesn't work
Why doesn't this command work? How can I correct it?
for /F %%i in ('dir c:\logs /A:-D/B') do @echo %%i:~0,5%
1
vote
2
answers
4k
views
XRDP (in a WSL distro) not connecting to remote desktop
So I was making a Batch file. By using it, I open a program in command line (WSL, to be specific). The program takes in some input. For an specific example-
i'm making a Batch file which runs wsl --...
1
vote
1
answer
1k
views
Windows BATCH file gives me weird spaces in my variable
I was trying to make a simple batch file that scans a variable X for any spaces and then creates a modified variable Xmodified that does not include any spaces. Here is the code I used:
@echo off
set ...
1
vote
2
answers
20k
views
Why does the Windows Batch script output the variable as "ECHO is off." instead of the actual value
I have written a Windows batch script to create an array and tried to print every element of the array.
However, the output is ECHO is off. instead of the actual value such as "Apple".
When ...
1
vote
1
answer
2k
views
Changing A Windows 10 Account Name With A Batch File [duplicate]
I've been looking around and can't find an answer to this.
i want to change an account name with a batch file
1
vote
3
answers
166
views
CMD crashes without any error when running Citrix clean up tool
I have had a cmd batch file to reset my Citrix receiver:
@echo off
set /p Choice="Do you want to reset Citrix settings? (y/n)"
if (Choice==y) (goto :RESET) else (exit)
:RESET
start "...
1
vote
1
answer
610
views
(net was unexpected at this time
I am trying to write batch file to map drive when needed but whenever I run it I get an error:
(net was unexpected at this time
@echo off
SET /P Site=Which site you want to map please type SITE ...
1
vote
1
answer
1k
views
Batch file with Powershell command quotes
I have created a script to change my IP address/mask and VLAN ID of an interface but the problem is that in order to change the VLAN ID, I need to execute a PowerShell command. My variable containing ...
1
vote
1
answer
2k
views
Windows Batch For Loop Filenames with Exclamation Point "!" Problems
Exclamation Points are my bane with Windows Batch. Say I want to just skip filenames with an ! in them.
I know for checking regular text in variables in a for loop, I can run:
setlocal ...
1
vote
2
answers
2k
views
Running file from batch file
I am working in Windows 10.
This is my code saved in .bat file:
%windir%\System32\cmd.exe "/K" C:\Users\Alex\AppData\Local\Continuum\anaconda3\Scripts\activate.bat C:\Users\Alex\AppData\Local\...
1
vote
1
answer
292
views
How to iterate through directory and concatenate names of folders into string
Similar to this question, but with folder names instead of with file names. The current code I have for concatenating files is
setlocal enabledelayedexpansion
set colorFileNames=
for %%f in (%CD%\...
1
vote
3
answers
1k
views
How to replace a letter from a text file?
I have a text file named, file.txt it contains,
i love bats and batch
i like to replace letter b with c
expected output in a separate file, output.txt ,
i love cats and catch
Important note : it ...
1
vote
1
answer
766
views
Batch: Unexpected Variable Results in Subroutine
An answer to a previous question suggests this FOR line. Now I am trying to use the variable. My batch script at present:
@echo off
cls
for %%G in ("3D Objects","Documents","Downloads","Music","...
1
vote
1
answer
3k
views
using path from registry in a batch file
I am pretty new to registry and batch files editing. I want to replace path C:\PROGRA~2\Java\jre8\bin inside my batch file to a more generic path so that each time I don't have to modify the path and ...
1
vote
1
answer
479
views
Batch file to configure notepad settings
I have plain text (.txt) reports, in order to be printed correctly (final users will print the report). I need to configure notepad settings. as:
margins:
let: 8
right: 8
top: 4
bottom: 4
font:
...
1
vote
2
answers
3k
views
Why can't use tracert command in batch file
I try to use Tracert command in batch file but its not working!
@echo off
title Network Tracer
Set /p Host= Please Enter Hostname or IP Address:
if defined Host (
tracert %Host% >output.txt
)
...
1
vote
2
answers
1k
views
Find folder using batch
I'm trying to make a script that helps to go through a big library with lots of folders, names and numbers.
The part numbers are divided in 4 parts XXX.XX.XX.XXXX.
To help the searching the library ...
1
vote
2
answers
353
views
Percents in batch
The following works in command line but not in a batch file:
ffmpeg -i ext_%04d.jpg video.mp4
%0 is parsed as a variable and I can't figure out how to handle it. Is it even possible?
edit : I know ...
1
vote
2
answers
272
views
Can I implement IF EXIST with a given file extension?
I'm in the process of making a batch script to autoexecute a program if a given file type (in this case specifically *.iso) is found. Here is the current direction I'm headed:
IF EXIST *.iso GOTO :...
1
vote
2
answers
500
views
Unknown parameter in ren command in batch file
I am new to batch file programming and I am analyzing an existing batch file, which was implemented by a former developer in our company. So I am trying to figure out what he intended to do. I have ...
1
vote
1
answer
5k
views
Trying to use a bat file but I get the error "7z is not recognized as an internal or external command, operable program or batch file
I assume I need to make Windows recognize 7z as something it can use but I don't know how.
I searched for answers and this one here said that I need to add the binary to my machine's PATH but I don'...
1
vote
1
answer
1k
views
How to use ! in edit/replace code in for loop batch
Im trying to test if a line contains a string of text with a for loop, and then remove that string if it is there.
for /F "tokens=*" %%A in (test.txt) do (
echo %%A | findstr /C:"[B]" 1>nul
...
1
vote
1
answer
4k
views
Execute a powershell command from batch
I need to split up a very long line in a text file (maybe hundrerd thousands of characters) into shorter lines (8184 characters) and a .bat cannot handle this task.
However, I found a PowerShell ...
1
vote
2
answers
11k
views
how to separate single text file into multiple text file by lines using batch?
I have running the following program,
@echo off
cls
set /p "filename=type file name>"
setlocal enabledelayedexpansion
for /r E:\ %%a in (*) do if "%%~nxa"=="%filename%" (
echo %%~dpnxa >>...
1
vote
1
answer
3k
views
How to automatically close batch program, but keep java program running?
I want to run the command "java -jar mc.jar", then automatically close the batch windows. Is there a way I can do this without closing the java program?
1
vote
2
answers
1k
views
Crop various image sizes to single size w/ ImageMagick
I have a large number of images of various sizes, all equal to or greater than 565x790. I would like to trim the edges of the image so that they are exactly that size. Is there a way to do this in a ...
1
vote
3
answers
21k
views
Calling a batch file with a string variable as a parameter only shows first word of string
I'm trying to call a batch file while sending a string variable, but when i try to get it it only shows the first word of the string.
before calling the other program i echo it to check if it is ...
1
vote
3
answers
2k
views
How to get the ver command to print out of a batch file?
I am having an issue with a build batch file from a third-party project I am working with. It does a check for if the OS is Windows by using the ver command. Unfortunately, I cannot seem to print the ...
1
vote
1
answer
105k
views
Copy files from Network Mapped Drive
I am trying to copy a file over from a mapped drive on a network to the current computer through a batch file.
I've already attempted the following below and still no results. The plan is to run a ...
1
vote
2
answers
350
views
Windows 10 how to create a command line program
I've just downloaded swagger-codegen-cli (doesn't matter what it is, it's just an executable jar) in a Windows 10 OS, which runs from the command line. So to execute it I must go to the corresponding ...
1
vote
1
answer
9k
views
Two commands in one batch file?
I have those lines of codes, they are working just fine, however I want to unite them in same batch file, and execute sequentially, without making separate batch files, as if for example I want Code 1 ...
1
vote
2
answers
8k
views
On windows: how to get last modified date (UTC time) of a file with wmic
I wrote the following batch in order to get the last modified date. The problem is that it gives it in clock time and not in UTC time. I know I have the lag in minutes but it is not that simple to do ...
1
vote
1
answer
2k
views
Windows batch powershell command inside FOR loop not working
I have the following for loop inside batch file:
for /l %%x in (1, 1, %k%) do (
set "psCommand=powershell -Command "$pword = read-host 'Enter Password2' -AsSecureString ; $BSTR=[System.Runtime....
1
vote
1
answer
9k
views
WMIC in for-loop
I'm trying to get WMIC output into a variable so I can process it further.
I have made a test batch file to illustrate the problem:
wmic PROCESS where "commandline like '%%teststr%%'" get ...
1
vote
1
answer
1k
views
Batch extracting multiple .aac tracks from an .mp4 using ffmpeg?
How do I create a ffmpeg .bat file that will let me drop in .mp4 file(s) and extract multiple .aac tracks without any converting or transcoding taking place ? I do know that there will always be 3 ....
1
vote
1
answer
555
views
Batch file/alias/powershell to activate/deactivate IE 11 proxy server
I would like to have a batchfile/cmd alias/powershell command to switch the useage of a proxy server in IE11 on and off, so basically to check/uncheck the following settings:
IE->Options->Connections->...
1
vote
2
answers
4k
views
Batch file to get remote system information in a loop
Sorry about the title, I struggled to explain it in one line.
I have a simple script which gets a remote systems status, and returns the line which contains the total memory, and outputs it to a file:...
1
vote
3
answers
3k
views
Fractions in Batch
Why does the following code return 0?
@echo off
set a=100
set /a a=%a%*(50/%a%)
echo %a%
pause
I assume it's because batch at some point evaluates (50/100) as 0.5 and rounds it down to zero because ...
1
vote
1
answer
3k
views
bash "wait" alternative for Windows batch script
In bash there is a option to wait for all the background process started by current shell using wait command.
e.g.
#!/bin/bash
{ sleep 5; echo "waking up after 5 seconds"; } &
{ sleep 1; echo "...
1
vote
4
answers
1k
views
Disabling the "Windows cannot find '[foo].exe'" popups
When I use the start command in a batch script to launch a program, I expect that program to be launched asynchronously; this happens exactly as I'd expect it would if the program that I'm launching ...
1
vote
3
answers
5k
views
How to receive a parameter in a batch file
I have asked a question, Use an environment variable to point to an "Open With" program, which received a fantastic answer.
To add myapp.exe, residing in %MYAPPSDIR%, to the Open With ...
1
vote
2
answers
3k
views
Batch: How to forward data to new CMD instance as arguments
I'm looking to call another CMD instance and pass data to it from the parent instance.
I'm aware of the general route of using variables, but it would not be feasible in this case as endlocal and ...
1
vote
2
answers
828
views
Error calling .vbs from .bat
I am currently trying to call a .vbs file from a batch file and it keeps giving me an error.
This is my batch file:
@ECHO ON
cscript "C:\Users\Alex.Newton\Desktop\VBScripts\First scripts\This is my ...
1
vote
1
answer
2k
views
'fsutil' is not recognized as an internal or external command in Batch Script
Here's my script which basically creates a file and converts it to a sparse file
SparseFileCreator.bat
@echo off
echo ************************
echo * SPARSE FILE CREATION *
echo *********************...
1
vote
1
answer
2k
views
batch file for hardcoding subtitles in multiple videos with ffmpeg
My question at the top:
What is the correct way to refer to a dynamic file name for the ass filter when using -filter_complex in ffmpeg?
The story and my attempt:
I have a folder that contains ...
1
vote
1
answer
194
views
Batch file executing differently than command prompt
I'm trying to make a jar file association patch for a friend of mine, and when I test the batch file on my computer and try to launch a jar file, I get an error saying Unable to access jar file. But ...
1
vote
2
answers
46
views
Is there a more compact way to use the IF loop functioning in a batch file?
The classical way is
if "%name%"=="john" goto ok
if "%name%"=="eric" goto ok
if "%name%"=="mary" goto ok
But can this be done in more compact way?
1
vote
1
answer
2k
views
Use existing explorer.exe instance when calling from batch file - Windows 7
In my batch file, I am calling a new Windows file explorer at a specific location by using the following:
echo off
explorer.exe "C:/Users"
The user then navigates to other folders as needed. Then, ...