110
votes
17answers
189k views

How can you find and replace text in a file using the Windows command-line environment?

I am writing a batch file script using Windows command-line environment and want to change each occurrence of some text in a file (ex. "FOO") with another (ex. "BAR"). What is the simplest way to do ...
57
votes
7answers
241k views

How to wait in a batch script? [duplicate]

Possible Duplicate: Sleeping in a DOS batch file I am trying to write a batch script and trying to wait 10 seconds between 2 function calls. sleep 10 does not wait for 10 seconds. I am ...
6
votes
4answers
10k views

Script to associate an extension to a program

My customer is replacing MS Office with OpenOffice in some workstations. My program export a file to Excel using the .xml extension (using open format) and opens it using the current associated ...
32
votes
7answers
40k views

Can Windows' built-in ZIP compression be scripted?

Is the ZIP compression that is built into Windows XP/Vista/2003/2008 able to be scripted at all? What executable would I have to call from a BAT/CMD file? or is it possible to do it with VBScript? I ...
11
votes
8answers
57k views

batch file to delete files older than a specified date [duplicate]

Possible Duplicate: Batch file to delete files older than N days How do I create a batch file to delete files older than a specified date? This does not seem to work; :: ...
65
votes
11answers
85k views

batch scripting iterating over files in a directory

How could I iterate over each file in a directory using for? And how could I tell if a certain entry is a directory or if it's just a file?
41
votes
13answers
38k views

Windows batch: sleep [duplicate]

How do I get a Windows batch script to wait a few seconds? sleep and wait don't seem to work (unrecognized command).
5
votes
5answers
5k views

How expand a CMD shell variable twice (recursively)

Using the Windows XP CMD command-line I can expand a variable twice as follows: set AAA=BBB set BBB=CCC for /F "usebackq tokens=*" %i in (`echo %%AAA%%`) do echo %i will echo CCC. I.e. AAA has been ...
7
votes
8answers
38k 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 ...
2
votes
3answers
3k views

How do I write a batch file to delete folders and files on a time basis?

Exact Duplicates: How to write a batch file to delete the files which are 5 days or older from a folder? write a batch file to delete 6 days older files from a folder write a batch file to delete 5 ...
26
votes
5answers
62k views

How to create batch file in Windows using “start” with a path and command with spaces

I need to create a batch file which starts multiple console applications in a Windows .cmd file. This can be done using the start command. However, the command has a path in it. I also need to pass ...
17
votes
5answers
23k views

How to automate a process with the sqlite3.exe command line tool?

I'm trying to bulk load a lot of data ( 5.5 million rows ) into an SQLite database file. Loading via INSERTs seems to be far too slow, so I'm trying to use the sqlite3 command line tool and the ...
11
votes
8answers
24k views

CMD.EXE batch script to display last 10 lines from a txt file

Any ideas how to echo or type the last 10 lines of a txt file? I'm running a server change log script to prompt admins to state what they're doing, so we can track changes. I'm trying to get the ...
16
votes
10answers
29k views

How do I get the result of a command in a variable in windows?

I'm looking to get the result of a command as a variable in a Windows batch script (see how to get the result of a command in bash for the bash scripting equivalent). A solution that will work in a ...
9
votes
6answers
65k views

Running a CMD or BAT in silent mode

How can I run a CMD or .bat file in silent mode? I'm looking to prevent the CMD interface from being shown to the user.

1 2 3 4 5
15 30 50 per page