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

3978 questions
26
votes
5 answers

Exit batch file from subroutine

How can I exit a batch file from inside a subroutine? If I use the EXIT command, I simply return to the line where I called the subroutine, and execution continues. Here's an example: @echo off ECHO Quitting... CALL :QUIT ECHO Still here! GOTO…
Brown
  • 1,642
10
votes
2 answers

Getting date in a Batch file

I know nothing about batch files and I need to automate an application. The application has two fields Today's date Yesterday's date In the batch file I have the application's location and my log in information. And additionally I need these two…
asmi
  • 101
8
votes
2 answers

How do I detect the number of parameters to a batch file and loop through them?

Is there an easy way to detect the number of parameters passed as arguments to a batch file, and then use for /L to loop through them?
builder_247
  • 341
  • 2
  • 6
  • 14
8
votes
1 answer

Can a Windows batch file call another program without waiting for that program to finish?

I'm using Windows 7, and have a simple batch file to copy portable executables off my thumb drive to %TEMP%, and then start them. The goal is to prevent Windows from holding my thumbdrive hostage until I kill all the programs I started up from…
iconoclast
  • 3,320
8
votes
3 answers

Is it possible to change the icon of a MS-DOS bat file?

I have a MS-DOS bat file that I have written. However, I am wondering is it possible to change the icon to something different?
ant2009
  • 3,115
6
votes
3 answers

What is the significance of a dot after a command in Batch?

When writing Batch files (.bat), ECHO. is used to print a blank line to the screen. How does this work? What is the significance of a . after the command name? From the tests below, it seems that executing a command like PROMPT. is identical to…
kiri
  • 987
6
votes
3 answers

Batch Removing Newline in txt files in Windows Command line (cmd)

There are unnecessary new lines in txt files which i am merging during batch processing. I am thinking fof first removing all new lines and then inserting only one. how can i do that in batch file
Mirage
  • 3,183
4
votes
2 answers

How to extract second word of the string via windows batch

I would like to request an assist for this case. I want to get the second word of title so that I could set it as target file. set title=THE PROGRAM TITLE HERE
4
votes
2 answers

What is the batch file command ": ="?

I have the following batch script: set logFile=%1_%time:~0,2%_%time:~3,2%.log set logFile=%logFile: =% Does anyone know what the second line is all about?
GorovDude
  • 367
3
votes
6 answers

How to perform wildcard string comparison in batch file

My batch file writes a list of files on screen where it contains the .cs extension for /F "usebackq delims=" %%A in (`cleartool ls -rec ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->"`) do ( if "%%~xA"==".cs" …
3
votes
2 answers

Finding a free port with batch

How can I find a free port with a batch file? I tried to run a loop and using the netstat -o -n -a it will increment a variable until the port is not found in the netstat list But I'm also not sure if this is the best way to find a free port. set…
Navy Seal
  • 143
3
votes
2 answers

using FORFILES in batch to delete tmp and bak files older than a week

I am having issues making this syntax work correctly. What I would like to do is remove all tmp and bak files from the specified directory and all subdirectories if the modified date is older than 7 days. for %G in (.tmp, .bak) do forfiles -p…
TWood
  • 317
3
votes
1 answer

Bat error: ) was unexpected at this time (for if label subroutine)

bash error: ) was unexpected at this time. I need do something on all users, exept Administrator and Public Batch file @echo off C: CD \Users for /D %%d in ("*") do ( IF "%%d" == "Administrator" GOTO NEXT IF "%%d" == "Public" GOTO NEXT REM do…
3
votes
2 answers

How to prevent batch file for loop echo brackets

How to prevent batch echo brackets Batch file @C: @CD \Users @for /D %%d in ("*") do ( @echo "%%d" ) Output C:\Users>() "Administrator" ... C:\Users>() "Public"
2
votes
1 answer

Copy list of files to new names

Windows 7 Pro I want to copy a series of files, all named "cover" from different directories to a single directory, and give them all new names. I need help with either of the below options: Option 1 Use a batch file to copy the source files to a…
1
2 3
12 13