Batch process all files in a folder #!/bin/bash for file in <path>/*; do dcm2pnm "$file" "$file".png --write-png done