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.
4,003
questions
223
votes
17
answers
183k
views
How to supress "Terminate batch job (Y/N)" confirmation?
In cmd, when we press Ctrl+C we get the target application terminated but if the target application is called from a batch file, we get this "Terminate batch job (Y/N)" confirmation. I can never ...
142
votes
13
answers
486k
views
Can you zip a file from the command prompt using ONLY Windows' built-in capability to zip files?
I have a batch file that outputs a text file. I thought it would be nice if I could zip it up too.
This will be used in an uncontrolled environment, so I can't make assumptions about the presence of ...
102
votes
4
answers
206k
views
How to check the exit code of the last command in batch file?
Inside a batch file on Windows, I use 7-zip like this:
...\right_path\7z a output_file_name.zip file_to_be_compressed
How could I check the exit code of 7z and take the appropriate action ?
95
votes
5
answers
238k
views
How to remove read-only attribute recursively on Windows
I need to remove read-only attributes of all files under a directory recursively on Windows using command line. Could you please provide an example on this?
93
votes
11
answers
180k
views
How to auto detect text file encoding?
There are many plain text files which were encoded in variant charsets.
I want to convert them all to UTF-8, but before running iconv, I need to know its original encoding. Most browsers have an ...
89
votes
11
answers
239k
views
Get current folder name by a DOS command?
Is it possible to get the current folder name (not current directory path) by using a DOS command? If so, how?
The closest I got was this but it doesn't do it:
for /f "delims=\" %%a in ("%CD%") do ...
89
votes
6
answers
169k
views
Variables in batch file not being set when inside IF?
I have two examples of very simple batch files:
Assigning a value to a variable:
@echo off
set FOO=1
echo FOO: %FOO%
pause
echo on
Which, as expected, results in:
FOO: 1
Press any key to continue ...
87
votes
5
answers
11k
views
How can I remove a forkbomb from the Startup folder?
I have an older laptop running Windows Vista, from about 2005 and I was fooling around with it a little bit. In a moment of sheer stupidity, I created a Batch file and put the following code in it:
%...
79
votes
7
answers
451k
views
How do I make a batch file wait / sleep for some seconds?
I use a batch file to start up a few of the programs I need running in the background. Up until now, I had used the pause command to execute it after some of the other start-ups finished. I would ...
76
votes
11
answers
48k
views
Determine if command is recognized in a batch file
I'm writing a bat script in which I invoke a program (such as javac). For simplicity, I want to check if the command exists before I run it. i.e. If the command exists in PATH.
For example,
if (...
75
votes
2
answers
78k
views
Does %* in batch file mean all command line arguments?
Does %* in batch file mean all command line arguments?
69
votes
11
answers
368k
views
How do I create a Windows Batch file that does not show the Command Prompt when executed? [duplicate]
I have installed a ruby gem called Redcar, which is launched from the command line. When it runs, it steals the shell until it terminates, so I have to create a new shell window to continue doing ...
65
votes
14
answers
126k
views
Batch convert encoding in files
How can I batch-convert files in a directory for their encoding (e.g. ANSI → UTF-8) with a command or tool?
For single files, an editor helps, but how can I do the mass files job?
59
votes
11
answers
46k
views
Renaming many files in Mac OS X, batch processing
I used to rename file in Linux via a rename command:
rename 's/old_pattern/new_pattern/g' *glob
Is there something similar in Mac OS X (Snow Leopard)?
58
votes
6
answers
412k
views
How can I convert a Windows batch script to a .exe?
I have a fairly simple batch script that I would like to execute using a macro on my fancy gaming keyboard. However, SteelSeries Engine only supports opening a .exe file with the macro buttons. Is ...