0

so I am wanting to convert a large number of files that all have entirely unique names using a SINGLE program that is run through command prompt.

Here is the command for converting one file:

bam2egg.exe Filename.bam Filename.egg

I want it so I can convert a large number of .bam files that all have unique names to .egg files with the same names. I assume you can do this using a batch file or maybe even one command but I am unsure how.

Help appreciated!

  • Seems like you're asking the same thing as this question: http://stackoverflow.com/questions/39615/how-to-loop-through-files-matching-wildcard-in-batch-file – hometoast Jun 08 '15 at 17:55
  • Thanks, that worked with a bit of editing. For anyone else wanting to do the same thing: for %%f in (*.bam) do ( echo %%~nf bam2egg.exe "%%~nf.bam" "%%~nf.egg" ) pause – gunshotproductions Jun 08 '15 at 18:07

1 Answers1

0

You will need to use a little command prompt scripting: the for loop. I'm not familiar with windows command prompt but a quick search found me this:

Iterate all files in a directory using a 'for' loop

What that might look like:

for %i in (*) do bam2egg.exe %i converted\%i.egg

In theory this will put your converted files in a subdirectory called "converted" outputted as "Filename.bam.egg".

Seeing as you are using panda3d you can also use a python script:

import glob
from subprocess import call
import os.path
for filename in glob.glob('*.egg'):
    output_path = os.path.join('converted', filename.rstrip('bam') + egg)
    call(["bam2egg", filename, output_path])

This will output your converted files in a a subdirectory called "converted" and the filename will be a more sane "Filename.egg"

Community
  • 1
  • 1
croxis
  • 21
  • 1
  • 3