1. #!/usr/bin/env python
  2.  
  3. import os
  4. from gimpfu import *
  5.  
  6. def batch_convert(img, layer, inputFolder, outputFolder):
  7.     # Iterate the folder
  8.     for file in os.listdir(inputFolder):
  9.         try:
  10.             # Build the full file paths.
  11.             inputPath = inputFolder + "\\" + file
  12.             outputPath = outputFolder + "\\" + file
  13.            
  14.             # Open the file if is a DDS image.
  15.             image = pdb.file_dds_load(inputPath, inputPath, 0, 0)
  16.             pdb.file_dds_save(image, drawable, outputPath, outputPath, 3, 1, 0, 0, 0, 0, 0, 0, 0, 1)
  17.            
  18.         except Exception as err:
  19.             gimp.message("Unexpected error: " + str(err))
  20.  
  21. register(
  22.     "python_fu_test_batch_convert",
  23.     "Batch Convert",
  24.     "Converts DDS to DTX5 W Mipmaps",
  25.     "JT",
  26.     "Open source (BSD 3-clause license)",
  27.     "2013",
  28.     "<Image>/Filters/Test/Batch DDS",
  29.     "*",
  30.     [
  31.         (PF_DIRNAME, "inputFolder", "Input directory", ""),
  32.         (PF_DIRNAME, "outputFolder", "Output directory", "")
  33.     ],
  34.     [],
  35.     batch_convert)
  36.  
  37. main()