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

3921 questions
213
votes
16 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
  • 4,799
  • 7
  • 31
  • 27
134
votes
14 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 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 third-party software products such as 7-Zip, etc.…
Aaron Bush
  • 1,483
  • 2
  • 11
  • 7
99
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 ?
Misha Moroshko
  • 7,423
  • 9
  • 26
  • 31
92
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,370
  • 3
  • 29
  • 36
92
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
  • 17,942
  • 25
  • 87
  • 119
88
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.…
Ethan Bierlein
  • 1,069
  • 2
  • 12
  • 20
88
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,632
  • 2
  • 16
  • 19
86
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,851
  • 9
  • 34
  • 35
74
votes
10 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
  • 771
  • 1
  • 5
  • 6
72
votes
2 answers

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

Does %* in batch file mean all command line arguments?
Matt
  • 6,231
  • 20
  • 57
  • 79
71
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
  • 810
  • 1
  • 7
  • 9
69
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
  • 835
  • 1
  • 6
  • 6
64
votes
14 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,092
  • 1
  • 12
  • 17
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,633
  • 8
  • 31
  • 43
54
votes
6 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…
Chase Sandmann
  • 1,143
  • 1
  • 9
  • 13
1
2 3
99 100