50,331 questions
-1
votes
0
answers
53
views
wmic os get localdatetime suddenly failing
Intro
I have the a BAT file I am executing through cronical ( a windows cron like service).
Everything was working fine for 10 days..and then today suddenly the timestamp calculation is failing, and ...
Advice
0
votes
1
replies
38
views
fc /b giving different results when using in a loop
I have a batch script compare.bat where I compare a 2 files using fc.
In my Example AA is different and BB and CC are identical.
When I use fc as in the top example Ex1 it preoduces " Files are ...
-1
votes
1
answer
107
views
Cron expression to call bat file with parameter failing [closed]
I have the following BAT file that takes two params; HOST, and REPORT_NAME. I want to call it from Cronical.
@echo off
setlocal enabledelayedexpansion
REM ===== 1. Read parameters =====
set "...
1
vote
1
answer
96
views
How to include sub-folders in an [Array]
I have the following script which works perfectly except for the fact that it only copies the .txt files in the main [top] folders and NOT the sub-folders as well.
How can I include the sub-folders?
@...
-2
votes
0
answers
93
views
Running several batch files and display their output in the installer
I'm trying to create an installer that runs several batch files - one after another (synchronically) and display their output in a custom page.
This is my code (took example from this solution):
[Code]...
Advice
0
votes
9
replies
86
views
Batch to add new file type (without loosing existing one)
I used a batch gnu for windows tool to split "file1.csv" files in multiple files. As result it creates a list of files placed in a secondary folder like:
- file1.csv_aa;
- file1.csv_ab;
- ...
-2
votes
0
answers
57
views
loop for typing words in windows batch script and passing it as parameter [duplicate]
I want to type multiple words, that will be stored in string separated by 'enter'. Something like this:
input = "word1
word2
word3
word4 (...)"
Here is my code
cd /d "%~dp0"
@echo ...
Tooling
0
votes
4
replies
109
views
Automating repetitive tasks with Ruby and Selenium WebDriver
I followed the advice from this question and I started to experimenting with Selenium, but I feel like it has to many limitations. Could you recommend something more suitable?
A simple program that ...
0
votes
1
answer
55
views
Batch script using query session and logoff is not logging out users from remote servers
I am trying to automate an application update across multiple Windows servers. Before the update runs, I need to log off all users (Active, Disconnected, Hung, etc.) from several servers, except the ...
Best practices
0
votes
4
replies
71
views
How do I set a .txt's contents from another directory to a variable in batch?
I'm making a jokey-joke batch script that needs a password input to get in. I'm trying to make a part of it where it re-writes a .txt file and generates random stuff and hides the password in there.
I ...
Advice
0
votes
6
replies
85
views
Batch file to find subdirectory
I have multiple directories and in each of those subdirectories, there's a subdirectory called !img which contains backup images of the previous directory. Like this:
Test1\!img
\Other\!img
\...
-4
votes
2
answers
125
views
Extract directory structure from for loop search [closed]
I am using a for loop to recursively search through a directory for files of a specific file type, and then extract them to a different location. Right now I extract all of the files to the same ...
1
vote
1
answer
116
views
How to make a batch file to ping hosts to confirm they are up?
I try to make a batch file to just confirm hosts are up. I have sections that work just fine but when trying to put them together it all goes to hell.
The code is as follows:
@echo off
setlocal ...
1
vote
3
answers
91
views
How can I convert this bcdedit command to a get a string assigned to a variable for reference in a batch file?
The code below shows the BIOS mode UEFI or Legacy if used in cmd (command prompt window) or in a batch file.
How to modify the below command line so that a variable can be used, for example BIOS_MODE, ...
3
votes
1
answer
113
views
Batch custom tee function redirect to file is inconsistent
I am trying to implement a minimal "tee" function in batch.
I followed an example as the base for my code, which uses tee_nt.txt as its source.
I've written a simple test to understand the ...
Advice
1
vote
6
replies
83
views
How can I setup a Batch file to recurse 2 levels of a directory and run a command?
I'm trying to write a Batch file that will recurse 1 level and for all the directories in that level, go in to each of them and run commands.
For example. In every directory in my current directory, I ...
Advice
1
vote
2
replies
94
views
Get cmd file for copying Files
I need to build a cmd file that copies "Merge.txt" from the same directory of cmd file to "D:\StackFlow\"
Note: I want to copy that file whenever I change the directory source
Advice
0
votes
5
replies
100
views
How to separate variables on each line in a batch SET statement?
I have some data fields gathered in a SET statement like this:
set "datastr=%num_cde%, %id_achat%, %modele%, %sysfam%, %serial%, %ldt%"
later assigned to an email body as:
SET "...
1
vote
1
answer
136
views
Escaping % from nested Batch scripts inside a loop
I have a batch escaping problem involving 3 files:
chain.bat conatins this code:
for %%x in (%*) do (
%%~x
)
b.bat contains this code:
chcp 65001 >nul
start chrome --profile-directory="...
-1
votes
1
answer
83
views
Saving matplotlib figures when running multiple subsequent python files via a .bat file on Windows
SET UP
I have multiple scripts that I execute with a .bat file, like so:
cd C:\\path\\to\\my\\project\\directory
echo Running script 1
"C:\\ProgramData\\miniforge3\\envs\\myenv\\python.exe" ...
11
votes
2
answers
812
views
Retain the exact modification timestamp of a file in a Git repository
I'm trying to persist the last modification timestamp of a set of files in a Git repository. I understand that Git doesn't natively support tracking filesystem metadata, so some sort of customization ...
Advice
0
votes
3
replies
115
views
CSV file editing via a 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
144
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
142
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 ...
-2
votes
1
answer
98
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
5
answers
211
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
261
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
114
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
110
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
106
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
193
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
83
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
256
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
99
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
74
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
129
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
100
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
201
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
141
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
88
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
221
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
201
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
239
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
94
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 ...
4
votes
1
answer
177
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
77
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
270
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
90
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
211
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
114
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....