batch-file

How do I prevent the "Could Not Find" error message from del *.txt?

In a Windows batch-file, this line: del *.txt Will give the error/warning message: Could Not Find C:\*.txt if there are no files matching the pattern *.txt. Is there a way to prevent that message? ...

Windows advanced file matching

I'm trying to use a batch file to list files in a directory such that the file name only (minus extension) matches only numeric patterns, e.g. something like 125646543.pdf which would be easy to express as a regex [\d]+\.pdf but of course I don't have such niceties with Windows-only mechanisms... I'm trying to do this with Windows-only m...

Regex to identify DOS environment variables within braces

The following DOS script snippet has a bug: if not exist %MyFolder% ( mkdir %MyFolder% if %errorlevel% GEQ 1 ( rem WARNING: the line above has a bug! rem %errorlevel% will be the errorlevel rem of the if statement because of the (parentheses) echo Error: Could not create folder %MyFolder% ...

Java Problem running a .bat file

I'm trying to run two bat files from a Java app. I'm using: try { Runtime rt = Runtime.getRuntime(); Process proc = rt.exec(fullCommand); InputStream stderr = proc.getErrorStream(); InputStreamReader isr = new InputStreamReader(stderr); BufferedReader br = new BufferedReader(isr); int exitVal = proc.waitFor(); System.out...

batch file Copy files with certain extensions from multiple directories into one directory

I'm a newbie, so bear with me... I am trying to copy all .doc files that I have scattered throughout several subdirectories of one main directory into another directory using a batch file. I have managed to get a filelist.txt of all the files (there are hundreds) out of these directories that I want to copy using: "C:\Main directory\s...

How can I suppress the "terminate batch job" in cmd.exe

I'm looking for a mechanism for suppressing the "Terminate batch job? (Y/N)" invitation that I get whenever I press CTRL-C in a program started from a batch file: batch file: jsshell.bat: @echo off java -jar build-scripts\contrib\rhino1.7R1.jar and then starting it on cmd shell by: > jsshell.bat which gives me a shell that can be...

DOS batch process to move files to relevant folders

I want to write a DOS batch process which will go through my Directory and move all *.txt files to a dest folder to starting with the first character of the txt files Ex. abc.txt will move to folder "a" def.txt will move to folder "d" and so on... ...

Correct InstallUtil Path To File Syntax?

I'm trying to install a Windows Service using a batch file, let's call it "installservice.bat". Inside the file I have the following commands: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe -i ".\MyService.exe" pause When I excute the batch file (running as administrator on Vista) I get this: Exception occurred whil...

Batch Script IF

I'm trial and erroring a trivial batch script: I need to execute the .bat and have it iterate through all the files in the current directory and delete all files (and subfolders) except for itself and two other files. This works: @echo off for /f %%f in ('dir /b c:\d\test') do (del %%f) This doesn't: @echo off for /f %%f in ('dir /...

Compress command results in corrupted zip file

I have a script set up to rotate some log files in windows, and as part of the process I'd like it to automatically compress the rotated file. To do this I use the command compress source.file destination.file.zip However, if I try to open the file, I get the message "The Compressed (zipped) Folder is invalid or corrupted" I've tried ...

Make windows batch file not close upon program exit

It's all in the title. When the program is over, I want it to say "Press any key to continue..." so I can scroll thru the output. ...

Batch/CMD: Finding out every single folder file meta.xml

Hello, i have a directory which contains the following: -directory -another directory -meta.xml -yet another directory -meta.xml ... So it needs to find in every directory 'meta.xml', all by itself (so that i dont have to type in every directory at the code) And i want that with EVERY meta.xml file a command is done. Is there ...

How to traverse folder tree/subtrees in a windows batch file?

In a windows batch file, is there a way to traverse a folder/subfolders hierarchy doing some action on each file? ...

CMD/BAT - Help determining date 36 days ago.

Each night I need to do work on a folder 36 days old from the current date. I have a system that writes files to a daily structure like below. I need to keep 35days worth on the local disk and so each night I need to archive off the 36th day. Here is the kicker... There are approx 2 million files per day, so I cannot efficiently scan ...

How do I get the command prompt do dissapear after starting a program via a batch script?

Hi there. I have a windows batch file which I run to start a java application. The problem is that I don't want the command prompt output to be visible after the app starts. And not only that,... I don't event want to see it minimised. I don't want it at all. Any ideas? Cheers!! ...

Need assistance padding numerical month and day with leading 0

I am working within a batch file and need to pad a single digit with a leading 0 if under 10. I have the values in environmental variables. They are month and day, I need to pad to match file structure I am working against. I am using vbscript to return a date that comes back in the following format "7/16/2009". Need it to look like ...

Batch file for loop statement

I've put together the batch file below; I don't have much experience with batch files and I can't figure out why the file fails with an error message stating that the: DO command was unexpected. Looking at the following code, does anyone know what I did wrong? Thanks. @ECHO OFF REM Set arguments supplied by Subversion SET REPOS ...

Batch file FOR/f expansion

I have a file (directories.txt) with directory names, each on a single line and I like to expand the line C:\Documents and Settings\%USERNAME%\My Documents In my script to the real user name running the script. However the echo comes out exactly the same as the line and %USERNAME% does not expand. FOR /f "tokens=*" %%X IN (directorie...

Login to a Linux server from a Windows system using batch files

Hello All , i want to make one script which will automatic telnet the system . I have to access from my system(Windows Xp) to my server(Linux) spawn telnet <machine ip> expect "login:" send "<username>\n" expect "Password:" send "<password>\n" Is the above script is correct? 1) If yes means, how can i access this script from my ...

installing MSMQ with bat file or some automated stuff

We are creating a service which requires MSMQ, and it might happen the boxes where we install doesn't have MSMQ installed. So I want some mechanism which can install MSMQ as a prerequisite when installing my service. Any suggestions?? Some how i manage to find from the below answer I am using the below in the .ini file & bat file but ...