batch-file

Concatenate a variable with a string

Hello all, I wrote a small bat file: @echo off rem runs the {arg[0].exe} - using its fully qualified name %~f1 IF %errorlevel% NEQ 0 (set boolResult=False) ELSE (set boolResult=True) rem case1 EVENTCREATE /T ERROR /ID 700 /L "MyTest Application" /D "exitcode: %errorlevel%; session id is %SessionName%" rem case3 EVENTCREATE /T...

VisualSVN pre-commit rule

Using this hook with VisualSVN, added to the Repository/hooks folder as pre-commit.bat My question is how do I add the rule that a comment must always start with a numeric value? I want the first part of the comment to always be the issue number from a bug tracker. Eg. "123 - this commit fixes issue 123" @echo off :: :: Stops commi...

Batch file to edit multiple .txt files

Hi, I have over 1300 .txt files where I need to edit the first line of text, replacing one name for another. Can someone please advise of the best way to achieve this? Any advice would be appreciated. Thanks Stu ...

capture any error in VBScript?

I have a batch file that calls a VBScript (.vbs) program. After calling it, my batch script checks errorlevel to see if the .vbs program failed. I can signal failure with an exit code in the .vbs program with WScript.Quit(1). However, I can only do that explicitly. If some unexpected run-time error happens, the .vbs quits with an err...

Executing an application without waiting in Batch file

Is there any way to execute an application without waiting in Batch file. I have tried the start command but it just creates a new Command window. ...

start a process in a .bat file but hide it?

I would like to launch one of my apps inside a .bat file but it is visible and taking up space in my taskbar. How do i launch the app and not have it visible? ...

windows .bat file how to recursively list all files of type *.mp3

hello i want to recursively list the absolute path to all files that end with mp3 from a given directory which should be given as relative directory. i would then like to strip also the directory from the file and i have read that variables which are in a for-scope must be enclosed in !s. is that right? my current code looks like this:...

windows bat file: how to strip the path-part from a absolute filepath

hello i have a variable like this: set file=c:\dir\foo\bar\file.txt how can i get just the path-part into another variable? echo %pathpart% should give c:\dir\foo\bar\ thanks! ...

Remove Trailing Slash From Batch File Input

I have a batch file that I want to improve. Instead of requiring a user to provide a folder path without a trailing slash, is there an easy way for me to just remove the last character from the path if there is a slash on the end? :START @echo What folder do you want to process? (Provide a path without a closing backslash) set /p datapa...

Batch file assign returned values from a command into a variable (from powershell)

i am refering to this question ASSIGN win XP commandline output to variable i am trying to use it on a powershell code segment so i typed powershell date (get-date).AddDays(-1) -format yyyyMMdd and confirm it returns like 20100601 but then if i tried to for /f "tokens=*" %a in ('powershell date get-date -format yyyyMMdd ') do s...

windows batch: react to command not found

hello, i want to write a simple batch script, that calls a certain exe, but if this one is not found, it should call another exe. so in pseudocode set file=c:\path\tool.exe if(fileexists(file)) { call file } else { call c:\somethingelse.exe } thanks! ...

[MS-DOS] Read command-line parameters to .bat from file

I have a build.bat file which uses %1 internally... so you might call: build 1.23 I wanted it to read the parameter from a separate file, so I tried putting "1.23" in version.txt and doing: build < version.txt But it doesn't work. Isn't this how piping works? Is what I want possible and if so how? ...

Batch file,executing second command if first command exit.

Hi, I have a batch file, updatesipversion.bat that is calling another batch file, template.bat. updatesipversion.bat code: set init=empty set main=svn propget svn:externals ./3c > install\msbuild\SipBranchDefaultDetailsTemplate.txt set error=update set action=empty call template.bat "%init%" "%main%" "%error%" "%action%" set init=em...

Python script names in tasklist

I am wondering, is there a way to change the name of a script so that it is not called "python.exe" in the tasklist. The reason I am asking is that I am trying to make a batch file that run's a python script. I want the batch file to check to see if the script is already running. if the script is already running then the batch file will ...

Problem parsing a list in batch

I am trying to extract tokens from a list of strings using a batch script, but for some reason it ignores my string if it contains an asterisk. An example to illustrate this problem is as follows: @echo off set mylist="test1a,test1b" set mylist="test2a,test2b*" %mylist% set mylist="test3a,test3b" %mylist% echo %mylist% for %%a in ( ...

Windows Batch Script to Replace Environment Variables in a File

Hi. I want to write a batch file that will take the contents of a file, and replace any environment variable references inside the file with the actual environment variable values. Is this possible? Basically, if a file had this: %PROGRAM FILES%\Microsoft SQL Server\ then I would want the file contents to become: C:\Program Files\...

How can a text file be edited from a Windows batch file?

I am trying to make a .bat file to edit the redirect in index.asp to be the filename of the file selected via the context menu option .bat file. I know how to replace the file: @echo OFF del/q D:\e-lib\index.asp copy %1 D:\e-lib\index.asp but not how to edit the contents so that the redirect within index.asp points to the filename of...

Windows command line compression/extraction tool?

I need to write a batch file to unzip files to their current folder from a given root folder. Folder 0 |----- Folder 1 | |----- File1.zip | |----- File2.zip | |----- File3.zip | |----- Folder 2 | |----- File4.zip | |----- Folder 3 |----- File5....

Copy & rename file using .bat file language?

I want to make a .bat to copy & rename a file multiple times. I want to have a list of names, and an original file, then I want to copy that file and rename it for each name on the list. How I can do this using a .bat file? Also is it possible to run winrar fromthe .bat to .rar or .zip every file after copying/renaming? Example: $fi...

Batch file to wait for other program to load/initialize, then execute command?

I need some assistance writing what should be a fairly basic .BAT file. I load my main program, but that program takes ~20secs to load and be initialized. I have another command-line API I can execute to interact with this above program, but obviously until the above program is loaded and initialized there's no point in trying. If the...