dos-batch

dos : delete is deleting the whole directory instead of individual files

I'm running a simple batch file which is generated by a vbscript to delete individual files, however when I execute it, it is blowing away entire subdirectories. Anyone have any ideas on this? below is the batch file. rem 2008-12-15D:\DP-Production\Administrative\BUSINESS\FileLink del D:\DP-Production\Administrative\BUSINESS\FileLink...

SVN Pre Commit Hooks

I am currently trying to extend our already existing (and working) pre commit batch file for committing to SVN. The first part blocks any commit that does not have comments and works as expected. The second part is an attmept to block users committing SUO files, however this is currently blocking all commits. My understanding of DOs sc...

Floating point division in a dos batch

Hi need to do a floating-point division in a dos batch. I didn't find a way to do it. Something like this : SET /A Res=10/3 returns a integer number. Is it possible to do it ? ...

How do I append to an environment variable in a batch file?

I don't know how to describe exactly what I'm trying to do but here's an example batch file that demonstrates what I can't figure out.: I've got a batch file. Inside that batch file I'm trying to create a directory: Set CopyFrom = %~dp0 if Exist "%ProgramFiles(x86)" ( Set TargetDir = %ProgramFiles(x86)%\My Directory Name has spaces...

how to get a UNIVERSAL windows batch file timestamp

Hello, I'm having trouble generating a timestamp in a windows batch file because I get diferent date formats on different windows versions. My machine: >echo %date% >Tue 11/17/2009 Friends machine: >echo %date% >11/17/2009 I guess there has to be some way of getting the date (11/17/2009) from both strings using for /f, I've been t...

How to call a MS-DOS batch program from delphi 2010 application

Hi there! I am trying to write a routine which will execute a DOS batch program from within a Delphi 2010 application. My old routine which works in Delphi 6 keeps giving me the error message:- "Project1.exe raised exception class EAccessViolation with message 'Access violation at address 7C82F29C in module 'kernel32.dll'. Write of add...

ShellExecute + runas with quotes (") in parametees, fails to call the executable/batch

I have tried calling a batch file with elevated permissions. For that I have called fallowing function: (ref - http://msdn.microsoft.com/en-us/library/bb762153%28VS.85%29.aspx) ShellExecute(this->GetSafeHwnd(), L"runas", strExecutable, strParams, 0 , SW_SHOW); The call successfully launches the exexutable, but if I add quotes to my par...

batch echo pipe symbol causing unexpected behaviour

I have a variable in my batch file and it contains the pipe symbol (this one: |) so when I echo the variable I get an error about a unrecognized internal/external command. I need a way to either get it to echo it correctly or better yet remove everything after and including the | symbol as well as any extra spaces before it. ...

find and replace backspace in a file with tab using windows batch script

I need to parse a file using windows batch scripts and replace all occurences of backspace (^H) with any other delimiter like tab. I searched in several forums but couldn't find a proper solution. Any ideas are most welcome. ...

Concatenating space-separated numbers together in a batch file.

I need to randomly generate a number of values in a batch file that share a certain range and concatenate them together separated by spaces. Everything works except for concatenating the space-separated numbers together. The specific problematic issue is concatenating with the numbers with spaces, how do I go about this? The relevent po...

Read each line in a txt file and assign variables using windows dos commands

Hi All, Iam copying the files from one path to svn working copy by comparing the those 2 folders using beyond compare commandline. Report will get generated after the comparison is done using beyond compare. If any extra files are present in the right side should get deleted from svn repsotiory. So iam using a below for loop to loop thr...

Logical operators ("and", "or") in DOS batch

How would you implement logical operators in DOS Batch files? ...

cleanup batch file

I'm writing a batch file to cleanup my source folders. I want to delete all wincvs generated files with a prefix of .# FOR /F "tokens=*" %%G IN ('DIR /B .#*.*') DO DEL "%%G" the problem I'm having is that it's not deleting my files within subdirectories. ...

Dos scripting - how to get a silent if but display the commands being called.

Script Example: @SET APPLY_ORA=YES @REM ... IF %APPLY_ORA%==YES ( @ECHO Doing Oracle CALL %SOME_ORACLE_SPECIFIC_COMMAND% %SOME_ORACLE_SPECIFIC_FLAGS% CALL %ANOTHER_ORACLE_SPECIFIC_COMMAND% %SOME_ORACLE_SPECIFIC_FLAGS% ) ELSE ( @ECHO Skipping Oracle ) The idea is that I do not want to see IF YES==YES ( ) ELSE ( ) printed, particularly...

How to spawn several processes from the Windows shell and wait for them all to complete?

Hi, i want to do the following from a Windows batch script: start proc1.exe start proc2.exe ... start procN.exe <wait for all N processes to complete> <-- What do i put here? So how do i wait for all spawned processes to complete? TIA. ...

Get maximum percent from csv

subject score studentid xx 23.22% 1 yy 34% 2 zz 55.2% 3 xx 88.66% 4 yy 23.76% 5 zz 78.04% 6 How to get max % and student id for each subject? ...

how to use goto in batch script

Hi All, I have written following code setlocal set /A sample =1 :first type C:\test.txt | find "inserted" if %ERRORLEVEL% EQU 0 goto test if %ERRORLEVEL% EQU 1 goto exam :test echo "testloop" >> C:\testloop.txt set /A sample = %sample% + 1 if %sample% LEQ 4 goto first :exam echo "exam loop" >> C:\examloop.txt endlocal b...

Changing font color in WordPad

Hi All, Is it possible to change the font color of text while redirecting it to WordPad? Examples: C:\echo greencolor >> C:\colors.rtf -----> This text should appear green in WordPad C:\echo redcolor >> C:\colors.rtf -----> This text should appear red in WordPad C:\echo browncolor >> C:\colors.rtf -----> This text should appear brow...

how to fetch exact string from a text file

Hi All, here is me requirement. I have one text file and I need to get exact specified string from that file C:>type small.txt | find "small2" small2 small22 small20 C:>type small.txt small2 small22 small20 C:>type small.txt | find "small2" small2 small22 small20 C:\ Here it is giving all the words instead of only "small2"...

Expanding arbitrary variable to a drive, path etc. in a DOS batch

Hi. I am using a dos batch which processes file using passed parameter: process.bat "D:\PROJECT\TEST FILES\test.pdf" 72 process.bat: gswin32c -r%2 -sDEVICE=jpeg -sOutputFile="%~n1-%%d.jpg" -- "%~1" We can see that the parameter is expanded to the file name in the batch: %~n1. However I was asked to rewrite the batch to read parame...