batch-file

how can I save the output of windows internal FTP client?

Hi, UPDATED: on win2k it seems it works OK. Sorry for the confusion. MS Windows Vista internal ftp client has a strange behavior. When redirecting its output and error to a file, the errors do not show up there: ftp -n -s:commands.txt host >output.log 2>&1 When running it from Task Scheduler inside a batch file, I don't get a...

How do I copy files using Windows Batch?

I have a directory with several subdirectories with files. How can I copy all files in the subdirectories to a new location? Edit: I do not want to copy the directories, just the files... As this is still on XP, I chose the below solution: for /D %S IN ("src\*.*") DO @COPY "%S\" "dest\" Thanks! ...

How to launch multiple Internet Explorer windows/tabs from batch file?

I would like a batch file to launch two separate programs then have the command line window close. Actually, to clarify, I am launching Internet Explorer with two different URLs. So far I have something like this: start "~\iexplore.exe" "url1" start "~\iexplore.exe" "url2" What I get is one instance of Internet Explorer with only the...

How to get current datetime on windows command line, in a suitable format for using in a filename?

What's a windows command line statement(s) I can use to get the current datetime in a format that I can put into a filename? I want to have a .bat file that zips up a directory into an archive with the current date & time as part of the name, eg "Code_2008-10-14_2257.zip". Is there any easy way I can do this, independent of the regiona...

Safely kill a process from .bat file

I have a VB6 application that needs to update it's self. For this purpose, the PM has recommended using a batch file that is to be launched from the application. The batch file should kill the process, download the new version from a local server, overwrite the old files and launch the application again. My problem with this is that I am...

How to retrieve a list of tasks and bugs from TFS in a batch file?

I would like to access the work items in our TFS programmatically. Shouldn't there be an obvious command line tool to extract such information? Or a WebService I can just call? I already have checked into using Excel - this is neat, but I want more hardcore... ...

DOS batch files: How to write to the prompt and stay in the same line to input text.

I like to know if there is a way to read the user input inside a batch file, because i have a file named: "fif.bat" that recives two parameters (just call them paramA and paramB) so i execute the file like this: fif paramA paramB I have to change paramA every month, but i call this file lot of times so i like to open a console and hav...

Equivalent of %~dp0 in sh

I'm converting some Windows batch files to Unix scripts using sh. I have problems because some behavior is dependent on the %~dp0 macro available in batch files. Is there any sh equivalent to this? Any way to obtain the directory where the executing script lives? ...

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? ...

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 program (using ShellExecute) The problem is that OpenOffice does not register the .xml extension associated with it. Manually association works...

Unexpected variable subst behavior in DOS .bat file

What will the following DOS .bat file code segment display? Why? (i.e. why doesn't it behave as you might first think)? set VAR=before if "%VAR%" == "before" ( set VAR=after; echo %VAR% ) [I do know the answer to this, but figured this valuable enough to post] ...

Redirect Stdin and Stdout to File

I'm currently the Teaching Assistant for an Introduction to C class. The class is being taught using Visual Studio, but when grading I just use a simple Windows batch script to process all the assignment submissions, compile them, run them on a test file, and redirect the output to a series of text files I can print out, mark up, and han...

How to automate JavaScript files compression with YUI Compressor?

YUI Compressor does not accept wildcard parameters, so I cannot run it like this: C:>java -jar yuicompressor.jar *.js But I have over 500 files and would rather not have to create a batch file like this: C:>java -jar yuicompressor.jar file1.js -o deploy\file1.js C:>java -jar yuicompressor.jar file2.js -o deploy\file2.js ... C:>java...

Search and replace with a batch file

I am writing a batch file script using Windows command and want to change each occurrence of some blank space with "," What is the simplest way to do that? ...

How do I perform string operations on variables in a for loop?

This sounds dumb, but I can't get it to work. I think i just dont' understand the difference between %%v, %v% and %v Here's what I'm trying to do: for %%v in (*.flv) do ffmpeg.exe -i "%%v" -y -f mjpeg -ss 0.001 -vframes 1 -an "%%v.jpg" This successfully generates a thumbnail for each of the movies, but the problem is: movie.flv -> m...

Why is there a difference between the encoding of the Windows Command Prompt vs. a batch file?

For example, suppose I have a batch file called 'test.cmd' and it simply contains: echo %1 I can call this directly from the command prompt with 'test.cmd some¬arg' and the result is that the string 'some¬arg' is printed. However if I place that same call in a second batch file, called 'tester.cmd' for the sake of argument, and I cal...

Is there a timeout for a batch file?

Hi, I am using a bat file on a Windows 2000 SP4 server to copy database files while the database is shut down. Once the bat file hits the xcopy command, it does the copy, but never returns to the bat file to continue with the other commands (start up the database, etc). I should mention that the xcopy takes several hours. Is there som...

Batch closes prematurely on a for /f command

I have a batch file (in windows XP, with command extension activated) with the following line: for /f %%s in ('type version.txt') do set VERSION=%%s On some computer, it works just fine (as illustrated by this SO question), but on other it kills cmd (the console window just closes) Why ? Note: the computers seem to have a similar ...

Batch file script to remove special characters from filenames (Windows)

I have a large set of files, some of which contain special characters in the filename (e.g. ä,ö,%, and others). I'd like a script file to iterate over these files and rename them removing the special characters. I don't really mind what it does, but it could replace them with underscores for example e.g. Störung%20.doc would be renamed ...

Can an explorer right click menu item be triggered from a batch file?

Subject says it all but he background: I want to trigger some TortoiseSVN action from a batch file? I suspect that I can do this by calling the right exe with the right args but I'd rather find a way to solve the more general problem of doing an arbitrary action. Edit: The reason that I don't just use svn directly is that TortoiseSVN d...