Questions tagged [batch-file]
A batch file is a text file containing a series of commands that are executed by the command interpreter on MS-DOS, IBM OS/2, or Microsoft Windows systems.
52,134
questions
0
votes
0
answers
7
views
Trying to make a 8-4 hexadecimal number generator but for some reason it gives me 4-4 numbers
@echo off
echo lol testing
pause
@echo off
Setlocal EnableDelayedExpansion
Set _RNDLength=8
Set _Alphanumeric=0123456789ABCDEF
Set _Str=%_Alphanumeric%987654321
:_LenLoop
IF NOT "%_Str:~18%"=...
0
votes
0
answers
15
views
Push script to other servers [closed]
Guys do you know the code for how to push my script
instead of going in the server 1 by 1
i have 100 server and i have a script that update registry,
i have a file name CRIpatch.cmd
what im doing ...
0
votes
1
answer
12
views
calling batch file with parameter in nodejs
To run a batch file from node i am using below given code and it is working fine.
const { spawn } = require('child_process');
const bat = spawn('cmd.exe', ['/c','D:/somefolder/bin/tools/caprequestutil....
1
vote
1
answer
22
views
How can I use CMD to create a subfolder in a folder and move every 10 files created there?
There is a cmd code (see code below). You can't do it in Powershell for I need it in cmd. This code with ffmpeg software slices the video into pieces. The point is, before ffmpeg works I create ...
-1
votes
0
answers
20
views
Input not working in batch rpg main menu script [duplicate]
Im working on a batch game and I've run into a major problem, on the main menu whenever i type 1 to launch the new game script it just stays on the menu, even when pressing 4 which is supposed to ...
-1
votes
1
answer
20
views
How to write a Windows batch file that will check for a registry key value, then change it if necessary? [duplicate]
We're trying to deploy a batch script to check a fleet of servers for their network time servers and update them if necessary. The value is located here:
reg query HKLM\SYSTEM\CurrentControlSet\...
1
vote
1
answer
25
views
batch file remove text before and after word
i want to remove everything before url=https:// and after .ap.ngrok.io mean I just want the code link d045-113-172-146-154
this is ngrok.log
t=2022-05-20T21:33:03+0700 lvl=info msg="no ...
0
votes
0
answers
23
views
Wait for a program to finish installing before running the next line. CMD Batch file
I'm trying to automate an installation process.
I have been using start /wait to wait for the installations to complete before moving to the next.
The issue I have is the setup.exe opens another ...
0
votes
0
answers
18
views
Running executables in parallel from a batch script [duplicate]
I have a Windows batch script which basically loops through a directory and searches for subdirectories, and then it calls an executable program (.exe), and gives the found subdirectory as an argument ...
0
votes
0
answers
22
views
how to use "for" loop to execute task with first 6 files? [closed]
I have a folder with some mp4 files. So I need to execute batch file with first 6 files from folder.
Example
FOR /F "tokens=*" %%G IN ('dir /b *.mp4') DO (
echo %%G
del %%G
)
pause
but the ...
0
votes
1
answer
15
views
how to run an executable remotely with psexec on multiple computers
I'm pretty new to batch scripting.
I was looking for a simple way to start an executable on several remote computers.
What I have come up with, until now, is to make a batch file which calls psexec ...
0
votes
0
answers
16
views
Reading a decimal value from a text value into 2 variables
Been trying to read from 2 seperate text files, 2 seperate decimal values. Unfortunately batch doesn't seem to be able to do this so, as I am just going to paste the values into another text document, ...
-1
votes
1
answer
18
views
Batch file to delete files if they exist with different file ending in another folder [closed]
I have a nicely housekept folder containing .mxf files. I monitor these with a script that converts those to .mp4 using ffmpeg. However, if a file is deleted from the folder contining the .mxf files, ...
0
votes
0
answers
23
views
Why curl gives ASCII / �~� char in JSON response?
i am calling a rest api, which returns data in json stream format.
But each json starts with some ASCII or �~� values as starting into it.
like this,
~Å{"a":"1"},
~3{"b":&...
0
votes
1
answer
20
views
How to retrieve date time with the correct time zone
In a batch file I retrieve the date time with that:
REM --------Retrieving date time
for /f %%x in ('wmic path win32_utctime get /format:list ^| findstr "="') do set %%x
set Month=0%Month%
...
0
votes
0
answers
38
views
I want to modify the batch file execution gauge bar
https://superuser.com/questions/1663472/increment-a-progress-bar-in-a-windows10-batch-file
This is the original code address.
.
.
I want to modify this as below.
I hope the gauge bar will continue to ...
0
votes
1
answer
35
views
How to send email alert via SMTP if .bat file fails?
New to Python. Im able to create script fail alerts for R files because the cmd files generate .Rout files(in this case LocationToBlockGroup.Rout) My python script-
import pandas as pd
import smtplib
...
-2
votes
0
answers
17
views
Search for a key word in all JSON files within a directory [closed]
I'm trying to find the word "leather" in a enormous group of JSON and JSON5 files, and then output in a TXT which files contain the word.
I've tried a few other things I've found on the ...
0
votes
2
answers
26
views
How to Extract and copy content from one file to another using batch script?
I have a main.c file which content looks like
const uint8 array1[] =
{
0x00,0x12 , ....
....,
....,
....,
}
const uint8 array2[] =
{
0x00,0x12 , ....
....,
....,
....,
}
/* Data dictionary */
const ...
-1
votes
1
answer
18
views
Batch find and replace only on lines that contain a specific text [closed]
I'm trying to do a "find and replace" into a text file from batch but only on specific lines, as such:
Before:
7,U7k956ykBJ,"GenericLine"
7,SwNZVX7SwPA2,"GenericLine"
7,...
-2
votes
0
answers
17
views
Batch script To delete a folder in a group of folders depending on a specified folder name
For example I have:
path- E:\what\ever
files in that path- logs_05-18-22
logs_05-11-22
logs_05-4-22
I have a batch script that is creating a new logs_***** ...
0
votes
1
answer
26
views
Batch: Using the find command when path contains wildcards
I have a file structure that looks like this:
%~dp0 > %USER% > %DATE1%_%USER%.csv
where I am using SET /P to create the USER & DATE1 variables.
I have a few queries set up to count the ...
0
votes
0
answers
27
views
SQL Export to excel file
Okay, So i've been working on setting up a script to export some data into an excel file.
So far everythings working, I'm using an ssis package in a batch script calling dtexec and when I run the ...
0
votes
0
answers
33
views
batch file will not read the entire csv file i have
I have a csv file with around 9500 rows and around 60 columns (if opened up in excel). I am trying to have the program read the 1st value in the row and output it to a txt file. Right now I have the ...
0
votes
0
answers
24
views
Batch file adding strange character in DO using %%i
Please let me preface with I do NOT know what I am doing. I need to perform a robocopy for some .xml files, and only want to copy files to replace files with an error. I have a query which has ...
0
votes
1
answer
16
views
If error with batch : not recognized as an internal or external command, operable program or batch file
Whenever I run the batch file and get to confirming username, it throws an error:
'ifyes' is not recognized as an internal or external command,
operable program or batch file.
'ifyes' is not ...
1
vote
1
answer
24
views
How to use a variable in "LEFT()" function in batch script [duplicate]
I'm afraid many would find this to be a dumb question...
@ECHO off
SET str=HelloWorld
ECHO.%str%
SET str=%str:~0,5%
ECHO %str%
The output is as expected:
HelloWorld
Hello
But this code below ...
@...
0
votes
1
answer
34
views
Rename file on Command Prompt
I have file like this and would like to rename:
Original File: 14876128.AOB.A14R2229-A14S2229.USER.pdf
Would like to rename like this: 14876128.AOB.A14R2229...A14S2229.051922.USER.pdf
14876128.AOB....
-1
votes
0
answers
15
views
why is my batch code not working? Problem with goto [closed]
When i start running my Batch file i get sometimes this error: "goto" cannot be processed syntactically at this point.
Now i fixed that but the batch file closes instantly after i set my ...
0
votes
2
answers
27
views
SQL SSIS Package ending at 33%?
So i'm setting up a script to get data from an sql database and output it into an excel file. When creating the ssis package in smss, and i select the option to run immedietly, it works. As soon as i ...
-1
votes
0
answers
16
views
Right Click on Selected Files in Explorer to Backup to dated subfolder
Looking for a way to backup files within file explorer by:
Selecting the files to backup
Right Click on them / Send to / Backup Files.bat
Then, the bat would make a Subfolder called "backup" ...
-1
votes
1
answer
22
views
How do I delete subfolders with the same name under multiple directories in Windows?
I have a folder tree similar to this:
main_folder\folder1\Debug\(file1.a1, file2.a2, file3.a3 ...)
main_folder\folder2\Debug\(file1.a1, file2.a2, file3.a3 ...)
main_folder\folder3\Debug\(file1.a1, ...
1
vote
2
answers
28
views
Why some varaiables need %% and others don't in Windows batch files?
For example, this:
ffmpeg -i %1 -c:v libx264 -preset medium -crf 30 -c:a aac "%~n1_OUT.mp4"
Does not need %%1 and %%~n1 respectively.
But this:
FOR /f %%f in ('dir /b .') DO somecommand %%f
...
-1
votes
0
answers
28
views
Running a batch File in AS400
Is there a way to run a batch file on my local as400 server from as400 command line as this batch file exists at a shared folder exists on my local as400 server.
batch file:
cd C:\D1
for /R %%...
1
vote
1
answer
28
views
Powershell download/install fonts "deploy"
I testing new powershell/batch download and install fonts oneliner, but with no luck so far (errors every time in cmd, under PS is OK)...
I believe there is problem with quotes somewhere
point is ...
0
votes
0
answers
18
views
Why FOR /F loop in batch file skips first empty token before the delimiter?
I'm struggling to understand the following behavior of the batch file.
This loop:
for /f "tokens=1,2 delims=$" %%A in ('echo 123$456') DO (
echo A-%%A B-%%B
)
...
0
votes
0
answers
7
views
TFS .bat - Get specific label version of repository
i have a problem. I would like to get a specific version of my project by searching for it by label. Basically I would like to have the user enter a label and get that version of the repository. How ...
1
vote
1
answer
27
views
I want to split the powershell-command txt document
I am a Windows 10 user.
This is the command below.
powershell -command "& {get-content log.txt|select-object -first 100}" >out_log111.txt
This is what I saw on the website. (Success!)...
0
votes
0
answers
8
views
From batch file execution some commands are not getting executed
Created a batch file with following lines
pyenv install 3.8.0
pyenv local 3.8.0
pyenv rehash
and executed in command line
observed first line executed successfully after that
next lines are not ...
-2
votes
0
answers
11
views
Changing the process name of a batch file everytime its ran [closed]
It doesn't matter if its by using a 3rd party app or code in the batch file itself,Is there a way to change the process name of the batch file automatically everytime i run it?(the one you see in task ...
1
vote
1
answer
24
views
Batch Script - Delete Columns in csv
I do need a batch script who will remove all columns in a csv, except column 1,2 and 5
My Code:
(for /f "tokens=1,2,5 delims=;" %%i in (Input.csv) do echo %%i,%%j,%%k) > Output.csv
Input ...
-1
votes
2
answers
39
views
Organize files into folders then subfolders based on filenames [closed]
A set of files have "Main Folder Name" (explicit) and a SubFolderName (hinted) in their filenames.
The intention is to just have them organized in new folders by "Main Folder Name" ...
-1
votes
0
answers
29
views
I have been tasked to compare the dates of two files and then if the file is 180 days old it has to be sent to an Object in a Cygwin command
I have initially converted a json file to a csv file from which I was successfully able to extract two columns 1)name and 2)last_modified(dates).(%%A = name; %%E = last_modified, cuz 1st n last ...
-1
votes
0
answers
69
views
findstr This is a batch file, but it doesn't work very well
[This is the content of my past question. 2022.5.18]
findstr This is a batch file, but it doesn't work very well.
I have to used commands findstr.
In the firewall_level1.netset file.
I'd like to ...
0
votes
1
answer
33
views
How do I run a MULTIPLE programs from command prompt as a different user and as an admin
Basically the below question, except I would like to launch multiple programs with a single command. Can the syntax be expanded to achieve this? The solution is offered by Coruscate5.
How do I run a ...
0
votes
0
answers
30
views
Batch File in Scheduled Task? How to run cmd script with attribute?
Problem I'm trying to solve:
I want to create a Windows Scheduled Task to run a command line: 'SetEnvCmd PROD'
In the code below, I have the file path to the batch file, but I'm not sure how to add ...
0
votes
1
answer
40
views
What does "2^>^&1" mean in batch script?
I'm just learning batch script. I'm reviewing the getJavaVersion.bat script on GitHub. I understood what the 2^>^&1 expression in the following line of code is used for. But I couldn't ...
0
votes
1
answer
33
views
Echo Information One Line Under FINDSTR Result
I am not sure if this is easily possible. I can easily parse any line that contains the same information. If I wanted to find all the lines that contain billing info in test.txt I could do findstr /...
0
votes
0
answers
31
views
How to stop R code from running until batch file is finished?
I want to run a code in R which first unzips large data files and then processes them. The unzipping process is done in a batch file which I run from within R and the processing is done with normal R ...
-1
votes
0
answers
21
views
Visual Studio for Mac - Run csproj file with batch commands [closed]
Our team has been developing a dotnet application on Windows. Now some of our teammates have started switching over to Mac. They have been running the Visual Studio for Mac in their machines. However, ...