Solved

Relatively Simple DOS Batch Script...

Posted on 2004-08-13
3
265 Views
Last Modified: 2010-08-05
I have an .exe that will convert a file of some type A (lets say *.flt) to some type B (lets say *.hpx).  
You just go to a command prompt and type: flt2hpx <inputfile> <outputfile>

What I want is some type of script that I can run that, for some directory, will convert all the files of type .flt to files of type .hpx with the same name (except the extension).

For example, doing the convertions individually by hand at the DOS prompt, I type:
C:> flt2hpx Brad_01.flt Brad_01.hpx
C:> flt2hpx something_04.flt something_04.hpx
.....
etc.

I want a script that will use the convert ALL the files in the given directory of type .flt to type .hpx like above.  Thanks!!

0
Comment
Question by:DiamonDogX
3 Comments
 
LVL 3

Expert Comment

by:aravindtj
ID: 11794059
Hi,
 Try this command.
ren *.flt *.hpx


If you want a script/ Batch file,

convert *.flt *.hpx    ; command example
------------------------------------
echo off
IF %1 == "" GOTO USAGE
IF %2 == "" GOTO USAGE

ren %1 %2
GOTO EXIT

:USAGE
echo "Usage: convert src_extension dest_extension

:EXIT
-----------------------------------------

All the best
0
 
LVL 2

Accepted Solution

by:
amg42 earned 50 total points
ID: 11794159
Create a .cmd file containing the following:

   @echo off
   for %%f in (*.flt) DO flt2hpx "%%f" "%%~nf.hpx"

Open a command shell, change to a directory containing your FLT files, and execute the script.
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 11794680
You should ask future MSDOS related questions at: Operating_Systems/MSDOS/

Anyway, for a batch file that does just what you want, you could do this:

::----8<-----------flt2hpx.bat ------------------::
@echo off

if [%1]==[] (
  echo Usage: flt2hpx.bat filename1 filename2
  exit /b
)
if [%2]==[] (
  echo Usage: flt2hpx.bat filename1 filename2
  exit /b
)

ren %1 %2
::----8<----------------end----------------------::

Usage of the above is:
flt2hpx.bat  Brad_01.flt  Brad_01.hpx

If that's not what you want, then specify a bit more, and I'm sure I/we could conjure up something. ;)

Good luck,
[r.D]
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now