quake 3 commands | Cell 8 | Cell 10 | Search

These scripts and commands are used to convert various image files to TGA format, with options to handle different file types (PCX, JPG, JPEG) and color spaces. They use tools like wal2tga, convert, and find to automate the conversion process in Windows and Bash environments.

Cell 9


for /r %%v in (*.wal) do "Z:\planet_quake_data\tools\Wal2TGA\wal2tga copy.exe" "%%v" "%%~dpv%%~nv.tga"

# TODO: bash uses glob, windows can use "or" keyword
#windows
for /r %%v in (*.pcx or *.jpg or *.jpeg) do convert -colorspace RGB "%%v" "%%~dpv%%~nv.tga" ; done

#bash
for i in $(find . -iname '*.pcx' -o -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.tga'); \
do if [ ! -f "${i%.*}.tga" ]; \
then convert -colorspace RGB "$i" "${i%.*}.tga"; \
fi; \
done;


convert -colorspace RGB pak0.pk3dir/models/deadbods/dude/dead1.pcx pak0.pk3dir/models/deadbods/dude/dead1.tga

What the code could have been:

bash
#!/bin/bash

# Define the base directory for the quake data
DATA_DIR="Z:\planet_quake_data"

# Define the tool executable and output directory
TOOL_EXEC="wal2tga copy.exe"
OUTPUT_DIR="$DATA_DIR/tools/Wal2TGA"

# Convert PCX and JPEG images to TGA
for image in $(find "$DATA_DIR" -iname '*.pcx' -o -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.tga'); do
  # Get the input file name and location without the extension
  IN_FILE="${image##*/}"
  OUT_FILE="${IN_FILE%.*}.tga"

  # Check if the output file already exists
  if [! -f "$OUTPUT_DIR/$OUT_FILE" ]; then
    # Convert the image to TGA using Imagemagick
    convert -colorspace RGB "$image" "$OUTPUT_DIR/$OUT_FILE"
  fi
done

Code Breakdown

Windows Script

for /r %%v in (*.wal) do "Z:\planet_quake_data\tools\Wal2TGA\wal2tga copy.exe" "%%v" "%%~dpv%%~nv.tga"

Windows Script (Alternative)

for /r %%v in (*.pcx or *.jpg or *.jpeg) do convert -colorspace RGB "%%v" "%%~dpv%%~nv.tga" ; done

Bash Script

for i in $(find. -iname '*.pcx' -o -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.tga'); \
do if [! -f "${i%.*}.tga" ]; \
then convert -colorspace RGB "$i" "${i%.*}.tga"; \
fi; \
done;

Single Command Example

convert -colorspace RGB pak0.pk3dir/models/deadbods/dude/dead1.pcx pak0.pk3dir/models/deadbods/dude/dead1.tga