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.

Batch processing is the execution of a set of commands or software programs without user intervention. Typically by scripting the job in shell scripts, power shell or with the command interpreter.

One of the old tools for scripting in the DOS era was a , but generic batch processing is not just about these.

There are many questions about batch renaming, for these we have the tag

4040 questions
233
votes
18 answers

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 remember an instance where I chose not to terminate…
Srikanth
  • 5,219
142
votes
12 answers

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 want to zip it too. This will be used in an uncontrolled environment, so I can't make assumptions about the presence of third-party software products such as 7-Zip. This needs to use Windows'…
Aaron Bush
  • 1,563
105
votes
4 answers

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 ?
98
votes
5 answers

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?
Mert Nuhoglu
  • 2,470
95
votes
11 answers

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 Auto Detect option in encodings, however, I can't…
Lenik
  • 18,830
92
votes
6 answers

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 . . . However, if I place the same two lines…
Brown
  • 1,682
91
votes
11 answers

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 set CURR=%%a echo.DIR: %CURR% Note: the above…
djangofan
  • 2,939
87
votes
7 answers

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 prefer to use the wait or sleep commands but they do…
Cegorach
  • 980
86
votes
5 answers

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: %0|%0 I ran this and I had to restart my laptop.…
80
votes
11 answers

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 (my_command.exe is a recognized command) then ( …
user46097
  • 841
80
votes
2 answers

Does %* in batch file mean all command line arguments?

Does %* in batch file mean all command line arguments?
Matt
  • 6,539
70
votes
11 answers

How do I create a Windows Batch file that does not show the Command Prompt when executed?

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 command line work. The shell I'm using is the…
Jake
  • 845
67
votes
15 answers

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?
desolat
  • 1,132
59
votes
11 answers

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)?
math
  • 2,693
58
votes
7 answers

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 there any way to convert the script into a simple…
1
2 3
99 100