61
votes
6answers
73k views

Logical operators (“and”, “or”) in DOS batch

How would you implement logical operators in DOS Batch files?
10
votes
5answers
21k views

Batch file variables initialized in a for loop

I have a batch file which initializes variables via SET inside a for loop, for a set of files on disk: for %%f in (%MYTARGETDIR%\*config.xml) do ( SET TMPFILE=%%F.tmp echo In loop %TMPFILE% ) ...
24
votes
17answers
29k views

How to check if directory exists in %PATH%?

How does one check if a directory is already present in the PATH environment variable? Here's a start. All I've managed to do with the code below, though, is echo the first directory in %PATH%. Since ...
16
votes
7answers
46k views

Can I mask an input text in a bat file

I am writing a batch file for execute some other programs. In this case I need to prompt for a password. Do I have any way to mask the input text. I don't need to print *** characters instead of input ...
7
votes
7answers
21k views

How to change Screen buffer size in DOS Command Prompt from batch script

I know you can do right click properties ->layout and there change it manually. But how would you go about changing it from a windows batch script? I know you can change size of it from script using ...
4
votes
2answers
1k views

Escaping a batch file echo that starts with a forward slash and question mark

Bit of a tricky one. How can I correctly escape the following in a batch file? echo /? display this help text This particular combination of characters is treated as an "ECHO /?" command: ...
5
votes
4answers
40k views

How to get file's modifed date on windows/dos command

I have been using the following command to get the file date, however the fileDate variable has been returning blank value ever since we moved to a different server (windows 2003) FOR /f %%a in ('dir ...
2
votes
5answers
4k views

DOS batch FOR loop with FIND.exe is stripping out blank lines?

This DOS batch script is stripping out the blank lines and not showing the blank lines in the file even though I am using the TYPE.exe command to convert the file to make sure the file is ASCII so ...
0
votes
1answer
7k views

MS Dos Batch delete old files in directory [duplicate]

Possible Duplicate: Batch file to delete files older than N days I'm trying to make a DoS Batch file to go through a directory with about 500,000 files in it, and i would like it to delete ...
0
votes
5answers
9k views

Windows batch file - The system cannot find the batch label specified

The Problem I'm having a problem with a DOS batch file and labels. I keep getting this error: The system cannot find the batch label specified What I've tried Two computers; a WindowsXP and ...
14
votes
7answers
41k views

Creating a file name as a timestamp in a batch job

We have a batch job that runs every day and copies a file to a pickup folder. I want to also take a copy of that file and drop it into an archive folder with the filename yyyy-MM-dd.log What's the ...
13
votes
5answers
9k views

Timer in DOS batch file

Can someone point me to a way of adding a timer to a DOS batch file; I need to track the time my batch runs from start. Many thanks J
7
votes
8answers
35k views

Batch File input validation - Make sure user entered an integer

I'm experimenting with a DOS batch file to perform a simple operation which requires the user to enter a non-negative integer. I'm using simple batch-file techniques to get user input: @ECHO OFF SET ...
6
votes
1answer
16k views

How to read input from console in a batch file?

How to read input from console in batch file. What i am trying to achieve is the functionality of scanf in c programming. How to do the same in batch file? thanks Nohsib
63
votes
7answers
128k views

How to create empty text file from a batch file?

Can somebody remember what was the command to create an empty file in MSDOS using BAT file?

1 2 3 4 5 6
15 30 50 per page