As of May 31, 2023, we have updated our Code of Conduct.

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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
24 views

Renaming multiple files in the command line

I have multiple files with names x_beta_5.txt x_beta_20.txt x_beta_300.txt and the list goes one how can the name of these files can be changed to x_5.txt x_20.txt x_300.txt I have tried using the ...
jarhead's user avatar
  • 101
1 vote
2 answers
132 views

How to search for all text lines that start with a tab character?

I need to find all lines in a text file that start with a tab character. I tried this command: findstr /B /R "\t" test.txt But it doesn't print any lines. I also tried with grep.exe (taken ...
Mercalli's user avatar
  • 209
0 votes
1 answer
17 views

Delete and replace desktop shortcut only if icon exists

I am updating a desktop icon for end users, not all clients have the icon. I need to deploy a script if icon exits delete and replace, if not stop and do not replace. I tried the below script, but ...
vader's user avatar
  • 1
0 votes
3 answers
70 views

How to delete all contents of a folder without deleting the folder itself

I am in the process of setting up a shared network drive, that gets emptied periodically. Its purpose is to provide an easy file sharing option for the users. Since I can't enforce them to always ...
fraenzz's user avatar
  • 23
1 vote
1 answer
27 views

Triggering the Windows Notification Center? [duplicate]

How can I create a desktop shortcut to trigger the Windows notification center (the right notification panel)? I believe I have Windows 11 Pro. If not, is there a batch command for opening up the ...
Tom Ng.'s user avatar
  • 11
1 vote
1 answer
19 views

Need Help creating a Right-Click menu entry

I have a .bat that I use frequently enough that I feel it warrants adding it to my Shift+Right-Click context menu. I do have SOME experience with editing my context menus. I added an entry to my Shift+...
Manson Casey's user avatar
1 vote
1 answer
41 views

Batch: How to show only errors in console output (ie redirect STDOUT to NUL and STDERR to CON)?

I'm trying to figure out how to show only errors on the console output (and suppress all other output) without redirecting to a file or using TEE, etc. I'm trying to get this to work for single ...
Paul π's user avatar
  • 37
0 votes
0 answers
53 views

Why is my file sorting batch script causing an infinite loop?

I am trying to find an efficient way to sort image files by name, and then loop this program over all subfolders in my chosen folder. I found a code that works in this thread. However, in order to ...
Pika's user avatar
  • 1
1 vote
0 answers
76 views

Why am I getting "The filename, directory name, or volume label syntax is incorrect." in this situation on Windows 11?

On Windows 11, I am trying to do this in a .bat file: start "nginx" cmd.exe /U /K "C:\nginx\nginx.exe" -c "C:\Users\John Doe\Documents\PHP-dev\Nginx\nginx.conf" -p "...
Tykell B's user avatar
-1 votes
2 answers
33 views

Batch file to open cmd.exe then run consecutive commands at prompt

I want to open cmd.exe, cd into a specific directory, activate a Python virtual environment, then move up two directories. I would have expected this to work: start cmd.exe /K cd /d D:\_LOCAL TORAGE\...
dsb27's user avatar
  • 1
0 votes
0 answers
26 views

Converting batch file to exe for Windows Embedded Compact (XP)

I’m having some trouble trying to create a very simple .exe file that starts a .url file in the same directory, when I try to run it, a pop-up message shows an error telling that: “<filename.exe>...
AleDetto's user avatar
0 votes
2 answers
33 views

BATCH: Correctly interpret environment variables passed by user through set /p

I want to support variable comprehension from user input in my script. >set target=%programdata% >echo %target% Gives me: C:\ProgramData All well and good, however... >set /p target= >%...
Luke Faez's user avatar
2 votes
3 answers
81 views

Seemingly impossible to extract URL string in between two text delimiters from 100's of messy Google News Alert emails with batch

For years Google News Alerts has sent daily emails when certain words pop up in websites, tweets, etc. and these emails (in HTML and .txt format) have one unique quality: there is no easy way to pull ...
user1798732's user avatar
-1 votes
2 answers
122 views

Getting the last 5 digits of the Microsoft Office product key with a script

When running the command cscript "C:\Program Files\Microsoft Office\Office16\OSPP.VBS" /dstatus you get the following output (keys hidden for privacy): Microsoft (R) Windows Script Host ...
CJ-Tech's user avatar
0 votes
0 answers
36 views

Run Single Instance of CMD via Registry for Multiple Files?

I have written a script to convert images with DirectXTex. I use %* in the command inside the script to handle however many files I pass to it by directly dragging multiple files onto it directly. It ...
Mr. Mendelli's user avatar
  • 1,239
1 vote
2 answers
99 views

batch script - How to conditionally redirect output stream(s)

In summary, the goal is twofold: Create a logfile that only contains commands that have failed, plus the error messages those commands generate. Prevent console output (success or failure), except ...
Paul π's user avatar
  • 37
0 votes
0 answers
26 views

Is it possibile to run multiple batch files that redirect their output to a single command prompt?

This is a relatively 'How To' question than a bug. I would like to know how it would be possible to have multiple instances of a batch program redirect their output to a single window. Is there any ...
01maxzie's user avatar
-1 votes
1 answer
50 views

How do I stop my batch script from outputting ECHO is off when it enters a variable into a file?

I made a script that pastes a variable into a file but whenever it pastes the text from the variable it says ECHO is off. Here is the script I used: @echo off color 0c title vmfMerge v1.1 by bub echo ...
Ethan Cato's user avatar
-1 votes
1 answer
67 views

How do I take contents of a file and to move it to another in batch script?

I am trying to made a batch script that the user types in the two file names they want to merge and then leaves them with a merged file. I already made it merge I just need to know how to copy the ...
Ethan Cato's user avatar
1 vote
0 answers
81 views

how to escape inside reg.exe windows registry - strange behavior

Everybody say that \ works as an escape inside reg.exe like: The REG command will interpret \ as an escape for the character that immediately follows it. source but I found it not a full correct ...
Badr Elmers's user avatar
1 vote
1 answer
29 views

How can I select only the basic Ethernet interface ipo Virtual Ethernet or other interfaces in a batch with WMIC NICCONFIG?

I have a small subroutine giving the description and index of the network interface called 'CARTE', so when called with %CARTE%=wireless, it returns the correct index of wireless interface (2), but ...
calade's user avatar
  • 53
4 votes
2 answers
109 views

how to display the size of USB/SD peripherals in my batch?

I made a small batch file to display the size, name and id of USB sticks and SD cards connected to a PC for test purposes. I tried to use :~0,-9% to shorten the size displayed in bytes, this works ...
calade's user avatar
  • 53
1 vote
1 answer
69 views

Failure to convert JSON to CSV file

I need to extract a particular anti-virus product scan results from a JSON file and list the elements in csv format for further processing. JSON file sample as below: Contents of a file scanresults....
Sam Chan's user avatar
0 votes
0 answers
98 views

How to convert JSON to CSV in batch command line with jq utility

I need to extract a particular anti-virus product scan results from a JSON file and list the elements in csv format for further processing. JSON file sample like: Contents of a file scanresults.json {...
Sam Chan's user avatar
0 votes
1 answer
58 views

Install Windows cmd in WINE

CMD implemented by WINE struggle to run complex batch scripts, I think it is possible to overcome by installing CMD.exe from Windows, but upon executing anything in it gives different meaningless ...
nonForgivingJesus's user avatar
1 vote
1 answer
42 views

How do I create a better drag and drop .BAT file that processes as many files as I select?

How do I create a better drag and drop .BAT file that processes as many files as I select? The purpose of this batch file is to convert any file with sound on it (mp3, ogg, mp4, etc) to a wav. I want ...
sp1792407's user avatar
3 votes
1 answer
28 views

7z batch file create individual( 7z or zip) with a master PW

I use this command with notepad. Save it as 7z.bat in a folder you want to individually .7z or .zip the files. With -p{pasword} -mhe *.txt @ECHO OFF FOR %%i IN (*.*) DO ( ECHO "%%i" | FIND ...
André Gravel's user avatar
0 votes
1 answer
41 views

Using a list in batch file

I need to copy a file if exist to a list of destinations. The Destination contain %variables% . When I run it appears to be using the %appdata% as stated in the array list instead of the c:\Users\NAME\...
user1791274's user avatar
1 vote
1 answer
53 views

Batch rename movie folder(s) to movie file inside of folder?

I would like to rename my movie folder names to match the movie file name inside the movie folder. The movie files have the right names but the folders do not. I've found batch file rename options for ...
PCRuns's user avatar
  • 11
1 vote
1 answer
106 views

How do I kill processes which are running with a given executable path?

I know already how I can kill all java.exe processes taskkill /F /IM java.exe But when it comes to a full executable path D:\Program Files\Java\jdk1.8.0_331\bin\java.exe, how do I do ? I'm asking ...
Sybuser's user avatar
  • 121
0 votes
1 answer
89 views

How to get specific string with batch for loop when it is in a line below a string we search?

I have an issue I am not sure how to deal with. I need to search a txt file where the search string is on the top but the actual data needed is in the next line underneath. Example: So I just noticed ...
Robert Corlin's user avatar
0 votes
0 answers
62 views

Batch Script For Loop to Websites with user input

I'd like to run a batch script on Windows that will prompt users for input (a list) that is then used to open up all the websites as tabs in one window (like a for loop) (not sure if this question ...
Mary Sojka's user avatar
1 vote
2 answers
44 views

WMIC ProcessID does not get parsed within the same command instance

I've got a batch script that I'd like to capture its Process ID but the PID is not being parsed from within the same command instance. For example, running the batch script with the following code ...
Joseph Karkar's user avatar
0 votes
1 answer
49 views

Checking if OneDrive is started before running script fails

I'm trying to create a bat script that checks if OneDrive is running, and if OneDrive is not running OneDrive.exe will be started. I have 2 issues: If OneDrive is running, it will close the cmd window ...
Benny Wijnants's user avatar
0 votes
1 answer
44 views

Is there a way to change the encoding in which the "test.txt" file is created to UTF-8 in a Batch file?

My goal was to make the "test.txt" file create it with "UTF-8" encoding instead of creating it in "ANSI". I leave attached the whole batch file: @echo off cls break > ...
Mirko Nastasi's user avatar
0 votes
1 answer
106 views

How to zip files in a specific date range

I'm looking for a way to zip files in a specific date range using a script. For example I would need something that zips files in a specified folder with date modified being 2020. I tried the solution ...
Pribovich's user avatar
0 votes
1 answer
47 views

How to convert .ppk key with passphrase to OpenSSH key in batch?

My question is related to that one How to convert .ppk key to OpenSSH key under Linux? But in the case when the .ppk can have an associated passphrase. According to the man page of puttygen “there's ...
Mauricio's user avatar
0 votes
0 answers
24 views

Why is Two-Level Variable Expansion Required When Using Bangs with Two Variables in a SET Command

For the following FOR loop, I can only get the statement set var%%a=%var!v!% to work if I add CALL and add 2 additional percent signs (one on each side) like so: CALL set var%%a=%%var!v!%% I ...
Mike Tompson's user avatar
1 vote
1 answer
44 views

Trying to Understand How Multiple Percent Symbols are Processed Around Variables

@echo off set var1=hello set var2=var1 set var3=var2 echo on echo 2. %%var3%% echo. echo 3. %%%var3%%% I have echo on so I can try to make better sense of the batch processing, though it really ...
Mike Tompson's user avatar
0 votes
0 answers
64 views

Assign a FOR variable to an Argument/Parameter

Is it not possible to use a FOR variable, like %%a, and assign it to an argument/parameter, like so: for /L %%a in (0,1,5) do ( echo Argument#(%%a) is %~%%a )
Mike Tompson's user avatar
0 votes
2 answers
124 views

Registry Query for batch script

I am trying to create a batch script, (only specifically batch script), to check if the latest Microsoft Office version is installed to my computer. If it detects the latest version, it will output ...
Tom Sim's user avatar
0 votes
2 answers
116 views

I am writing script in batch command and I am trying to replace a variable inside a loop

script 1 echo off set /a flag = 0 set /a flag = 1 pause script 2 echo off set /a flag = 0 for /l %%x in (1,1,3) do ( if %flag% == 0 (set /a flag = 1) echo %flag% ) pause script 1 is working ...
emanuel abraham's user avatar
0 votes
0 answers
114 views

Windows: Batch script to map a remote computer's share folder using a local login/password on THAT computer

I have a non domain computer I am running a shared network folder from, and that I connect with using an account that's locally on that computer. Doing it manually via the Map A Network Drive in ...
DGPortal's user avatar
1 vote
1 answer
36 views

Delete File 'i' to 'n' With Batch

I need to delete some files in a directory. They are all numbered like file1.txt, file2.txt,...,filen.txt I want to ask users the number of files they want to delete (called x), and just delete from ...
Helena's user avatar
  • 13
0 votes
0 answers
63 views

Trying to Echo Array Values by Referencing the Array.Length Variable

I'm trying to output the contents of an array index # by referencing the index # using the A1.length value. But since I still don't fully understand the expansion of variables, the most I get for ...
Mike Tompson's user avatar
0 votes
2 answers
77 views

Rename specific files and move to proper directories (Batch? Powershell?)

We have files (with no extension) that are dropped by clients in a shared directory: \\\Server\SharedDirectory\BRSURVEY802DATA \\\Server\SharedDirectory\BRSURVEYLOGINDATA \\\Server\SharedDirectory\...
MChalut's user avatar
5 votes
3 answers
778 views

What do you call the language you use in CMD nowadays? [duplicate]

so, I've long been afraid to refer to "that language you use in batch files and in the cmd shell" by name. It's embarrassing to admit that i don't know what it is called anymore. The only ...
Frank Thomas's user avatar
  • 34.7k
-1 votes
1 answer
79 views

Code that batch renames all .png files with increasing numbers, but how to i add so that the same happens with .jpg files too?

Workflow use (cd filepath) first write (ls) to get the files read code that works with .png files only: Get-ChildItem *.png | ForEach-Object -Begin { $count = 1 } -Process { Rename-Item $_ -NewName &...
Jonas Helt's user avatar
0 votes
1 answer
28 views

Not getting the right answer when dividing

echo off title Numbers Part 3 color a goto input :input echo what to divide? set /p by= cls echo %by%? ping localhost -n 2 >nul cls echo Well, %by% by what? set /p with= pause cls echo Great ping ...
DLAND GAMES's user avatar
0 votes
0 answers
39 views

clip command error in batch

I have a script file that prints something, then with this command: .\path.py |clip I send the output directly to my computer clipboard, so if I press Ctrl+V I can instantly paste it. It works ...
martinotecco's user avatar

1
2 3 4 5
78