Solved

Relatively Simple DOS Batch Script...

Posted on 2004-08-13
3
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
A short article about problems I had with the new location API and permissions in Marshmallow
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Simple Linear Regression

632 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