50,336 questions
Advice
0
votes
2
replies
81
views
CSV file editing via bat file
I have a report CSV file that has some special characters in the header row. I would like to set up a short script in a .bat file to remove these characters, so i can schedule a task to automatically ...
0
votes
3
answers
114
views
batch renaming of numeric files
I would like to rename a bunch of files in a given directory that are already present in ascending order to another line of consecutive ascending numbers. The goal is to close gaps in between and get ...
Best practices
1
vote
4
replies
121
views
Fastest way to count lines in a .csv from a .bat file?
I have this .bat file that I use to open .csv files, which counts the lines in them and uses Excel to open if under a million records and a separate program to open if more than a million records. The ...
-1
votes
0
answers
47
views
Jenkins is unable to locate the executable file after extracting the Nexus NuGet package
I attempted to execute the following command in a Jenkins batch script to run the executable named "GitFetcher.Exe," which is located within the tools directory of "IB.SO.AutoUtility.&...
-2
votes
1
answer
67
views
DO Error during String Replacement using Windows Batch Script
I obtained a batch script from Google AI for performing string replacement on the content of a list of text files in Windows. This is what I got--with a little tweaking, first. (Just testing at this ...
1
vote
4
answers
170
views
How to get from a url string the path to a file with a FOR loop in a Windows batch file?
Given is a string which is a url of a file, e.g. http://url.com/file.zip. I want to extract the path without the file name, i.e. http://url.com/.
My idea for doing this was to break down the string ...
1
vote
3
answers
245
views
How to convert a batch to Powershell parallel processing to run over thousands of input files?
I have a large number of files (about 3800) that I want to run a program over. The program reads a WAV file and makes a short .TSV text file containing the WAV's lip-sync data (but that is by-the-by ...
-1
votes
2
answers
96
views
Passing variable with leading zero to BAT file causes error [closed]
My bat file named A.BAT is:
@echo off
set /a file = %1
set /a group = %2
@echo file is %file%
@echo group is %group%
ren %file% myfile-%group%_%date%.dat
exit
=============...
1
vote
1
answer
103
views
Windows batch file cuts off file extension in for statement
I noticed that some software I use, AutoDarkMode, doesn't randomize the first wallpaper it switches to, so I thought I'd write a batch file to do it by copying one wallpaper in the folder and renaming ...
-3
votes
1
answer
97
views
how to change parent cmd windows directory in go
I have a cli app written in go and when it closes I want the directory to move to the selected one. When I close I wasn't able to find any way for that to happen so I tried making a .bat wrapper for ...
0
votes
2
answers
177
views
How to accurately extract a block of text with CMD BATCH?
I'm trying to output part of a file (the text enclosed between :begin(...) and :end(...) markers) using a BATCH script. The target is pure ASCII text but it may contain blank lines and symbols; the ...
2
votes
2
answers
80
views
Passing a string containg a £ sign to a command from a windows batch file
I am trying to create a trivial .bat file to act as shortcut to invoke a python script including a password that include a £ symbol.
This fails because batch treats the £ as a box character
I thought ...
2
votes
3
answers
226
views
Capture stderr separately in file while also including it in live output
Problem
Given some arbitrary process that may or may not output to both stdout and stderr, I need a way to execute that process on the command line in Windows that captures stderr on its own. I also ...
1
vote
2
answers
94
views
batch file to delete files from network share based on filename
I use an enigma2 receiver to record movies and TV shows.
One recorded file has additional files:
filename.ts
filename.eit
filename.ts.ap
filename.ts.cuts
filename.ts.meta
filename.ts.sc
I copy only ...
2
votes
1
answer
61
views
MediaInfo CLI; get item within a loop
I need to get the mediainfo item "Bits-(Pixel*Frame)" from every mp4 file of a folder.
If that item doesn't exists (It doesn't for all movies),
I will try to derive it from other items.
So ...
2
votes
1
answer
117
views
Create shortcut to batch file with "cmd /c" in VBScript?
I'm working on a VBScript to create a shortcut link to a batch file (the batch file downloads and launches a frontend Access database copy). The following code technically works but the shortcut link ...
1
vote
3
answers
93
views
Windows cmd script to loop through subdirectories and call another script
I would like to write a simple Windows batch script that, given a directory containing a set of subdirectories, loops through them all and calls a batch script of the same name in each. The code I ...
0
votes
3
answers
164
views
How to write a batch file that processes a maximum number of files concurrently
I have a folder that contains 1000 .wav files on a Windows 7 system.
I have fdkaac.exe in the system environment path.
If I run the following batch file:
for %%i in (*.wav) do fdkaac.exe -b256 -w20000 ...
-1
votes
1
answer
131
views
Execute arbitrary raw PS code including # comments and parentheses embed in a batch script [closed]
A single (hybrid) file can contain both Batch and PowerShell script without generating extra temporary files by leveraging the comment syntax of each language. This allows the Batch interpreter to ...
0
votes
0
answers
79
views
Can someone explain why in Batch Script IF 08 GEQ 4 is FALSE?
In Batch Script, when comparing a 2 digit number to a 1 digit number 08 & 09 are treated as low numbers but everything else works as expected.
So if you run the following:
IF 01 LEQ 1 ECHO 01
IF ...
0
votes
1
answer
212
views
Not equal operator not working with WMIC command in for loop of batch file
I wrote this batch to get the number of active processes given a certain command line value, but the not equal operator I use in the query to exclude WMIC.exe itself doesn't work, and the batch ...
2
votes
3
answers
177
views
Powershell multiline output into Batch variable
How can I put the entire Powershell output into a Batch variable?
Another post has suggested
@for /f "delims=" %%a in ('Powershell -C Get-Content myFile.txt -Raw') do Set "myVar=%%a&...
-1
votes
3
answers
168
views
PowerShell Find and Replace: Set Content not recognized when called within batch file [closed]
I'm attempting to do a simple find and replace using the Powershell Get-Content and Set-Content commands. In the Powershell terminal, I am calling the following expression:
(Get-Content test_file.yml) ...
-1
votes
1
answer
84
views
How to prevent batch script from exiting prematurely? [closed]
In the below batch script, the script exits right after the datapatch command.
The datapatch command executes successfully but none of the code in the if/else clause is executed.
:: Define env ...
3
votes
1
answer
74
views
Why is appending to User Environment Variable PATH without duplicating is not working for the last path in Windows 11 command line?
I looked through a few solutions here and found an almost working script to append to the user Environment Variable PATH without overwriting the existing path and not clutter it with system's EV's ...
-1
votes
1
answer
69
views
Changing the date format in a CSV file using a Windows Batch Script [closed]
I have a CSV file and need to change the date format in each record within a specific field.
The file has headers and is comma delimited.
I need to change this:
Despatch_date [date],Order_Number,Name,...
2
votes
4
answers
204
views
How to write a line feed <LF> to a file?
The following Windows batch file sets the contents of the out.txt file to two ASCII characters, namely: X and <LF> (0x58 and 0x0A ).
@echo off
SETLOCAL
SET LF=^
set /p=X^%LF%%LF%<nul>out....
0
votes
1
answer
84
views
Get batch program to process files in subdirectories
I have this simple batch file I'd like to process files in subdirectories. I've played around with the for /R but I can't seem to get it to work. Any help would be very appreciated.
Thank you.
Here is ...
1
vote
0
answers
195
views
build.bat fails to find vswhere.exe and git describe when building MPC-BE on Windows
I'm trying to build MPC-BE, an open-source media player for Windows, using the instructions provided in Compilation.txt and the GitHub README, because I want to add some features to allow external ...
2
votes
1
answer
102
views
Calling another batch file, doesn't seem to work?
Below is code for a batch file, loosely based on something i found on the internet. Ultimately, I'm trying to call one of two different batch files. It doesn't seem to acknowledge Bob'sbatchfile.bat....
-2
votes
1
answer
264
views
Problem using Task Scheduler to run batch file silently [closed]
I have a scheduled task, which runs a batch file every 3 minutes.
This batch file checks the running task list, looking for a certain running task.
If the task is running, the batch file exits.
If the ...
2
votes
1
answer
89
views
Commenting via REM and :: doesn't work in batch script
I just want to leave a reminder about the %~ symbol combination, but my running my batch file outputs this:
C:\Users\batch\batch>add_one2The following usage of the path operator in batch-parameter
...
2
votes
1
answer
108
views
cmd batch execution adds a space after echo
When I run a script, for example one that says
echo a>>1.txt
the command line interpreter adds a space; so in the command line, executing the above says
echo a 1>> 1.txt
And of course, ...
1
vote
1
answer
157
views
how can i close only windows that have a name using . bat
I want to close a specific Excel window without closing the others, using a common .bat, how could I do it?
I tried using this command:
@echo off
powershell -NoProfile -Command ^
"Get-Process ...
1
vote
2
answers
74
views
Batch file if condition to check file type failing under specific conditions
I have been at this for a few days and can't figure out why this is not working.
I had made this to run with lf file manager but I'm testing it from command prompt with file.bat test.mkv or file.bat ...
4
votes
1
answer
189
views
`%~dp0` doesn't always return the current directory [duplicate]
I put Daily Test Run.bat inside E:\Test folder. This is the content of the bat file:
@echo off
cd /d "%~dp0"
echo %~dp0
cd /d E:\Dev
cd /d "%~dp0"
echo %~dp0
Then I cd to E:\...
2
votes
1
answer
119
views
nested pushd does not popd in cmd, is this a bug?
see this example please:
C:\
..ex1\
....start.bat
....111\
......1.bat
......222\
start.bat:
@echo off
pushd 111
call 1.bat
popd
echo CD is wrong:%cd%
pause
1.bat
@echo off
setlocal
pushd 222
...
5
votes
1
answer
215
views
How does Rust's Command handle cmd.exe and batch script arguments?
A while ago there was a security advisory published for Rust that the standard library's Command API was not sufficiently handling arguments passed to cmd.exe and .bat files such that malicious ...
0
votes
1
answer
53
views
Call batch function fails with path containing spaces and double quotes
I have a function that calls a program, it is trying to run a pkzipc with a path parameter that has double quotes and spaces. I have tried to escape spaces and quotes in different ways as mentioned in ...
0
votes
0
answers
91
views
Is there a way to launch an RDP file with batch?
I have a file on my Desktop named 3390.rdp, complete with all login credentials. I'm trying to use it to connect to a Ubuntu installation on WSL2. When I open the Ubuntu "app" manually, and ...
0
votes
1
answer
95
views
How to read only specific folders and sync data using winscp batch file?
I am trying to write the batch script but not sure how to check the below condition.
I want to read all 3-digit number's folders and the 'data' folder only as first level directory, and inside these ...
0
votes
1
answer
71
views
Windows command script to copy to a directory that has changing version number
In a Windows OS and using batch file commands, how can I program a script to copy a file into a directory location that changes with unpredictable version numbers?
Say today I have this C:\Program ...
0
votes
1
answer
75
views
How to kill processes in javascript on web?
How do i run batch from the web locally?
I'm trying to kill a process locally (sas.exemy own file) but from web.
0
votes
0
answers
62
views
How to know a windows title of a process after launching it, but that process changed the title
This is puzzling to me. I launch the a process via command line or a batch file in windows:
>start "MY_TITLE" one_process.exe %some_arguments%
So ideally the application (window) title ...
1
vote
3
answers
140
views
Reusable subroutine in batch file
Trying to figure out the syntax in a batch file subroutine so it could be reused with a passed parameter.
Main portion of batch file...
Set PC=THISISATEST
Call :ToLowerCase
Subroutine...
:ToLowerCase
...
0
votes
1
answer
261
views
Why does the command source not work on Windows - cannot activate venv?
I try to setup a virtual environment for a Python project, and the command source doesn't work:
C:\Users>source MyEnv
'source' is not recognized as an internal or external command,
operable program ...
0
votes
1
answer
140
views
Why does 'set /a counter=counter+1' work without using %% in a batch script?
in this code I think I have to write set /a counter=%counter%+1 but I just tried write it without %% and interestingly it works I don't how?! can anyone explain it
@echo off
setlocal ...
2
votes
2
answers
84
views
Findstr will not redirect to file
-> I want to find this string in the text file
flashwareFileName="FL_992920900X_0143__V001_S.pdx"
Attempts:
findstr /s "=\"FL_" *.xml > temp.txt
findstr /s "=FL_&...
0
votes
1
answer
62
views
Nested For loop in bat with arrays
I'm trying to figure out how to get this nested loop to work without delayedexpansion. My original block shown below works as intended, but after writing it, I discovered I can't save the changes to ...
0
votes
2
answers
53
views
Compare with double quote in batch file
Basically the same as compare a character with double quotes " in windows batch
But when I use that answer I get an error:
( was unexpected at this time
set foo="foo"
if %foo:~0,1%==^&...