I have a large number of rasters (JPG format) and I want to convert them to TIFF format to folder called "OtherFormat" in env.workspace with arcpy. In my code I try to convert all JPGS using Raster To Other Format (Conversion) and understand that I can do it if I write the exact name of the raster. But I have 120 rasters so I tried to use asterisk:

import arcpy,os,sys,string
import arcpy.mapping
from arcpy import env

env.workspace = r"C:\Project\out"
print 'converted'

but get the following error:

ExecuteError: Failed to execute. Parameters are not valid.  
ERROR 000732: Input Rasters: Dataset *.jpg does not exist or is not supported Failed to execute (RasterToOtherFormat). 

2 Answers 2


You need to make a list of the jpeg's and the n loop trough them. You can use the glob module for that:

import arcpy, os , glob

outworkspace = r"C:\Project\out\OtherFormat"
listOfJPG = glob.glob( r"C:\Project\out\*.jpg")

arcpy.RasterToOtherFormat_conversion(listOfJPG , outworkspace ,"TIFF") 

print 'converted'
  • warrieka,i get en error: Traceback (most recent call last): File "C:\Users\yaron.KAYAMOT\Desktop\stack 1.py", line 10, in <module> arcpy.RasterToOtherFormat_conversion(jpg, name,"TIFF") File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\conversion.py", line 2753, in RasterToOtherFormat raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Output Workspace: Dataset 2015-03-25_084900.jpg.tif does not exist or is not supported Failed to execute (RasterToOtherFormat).
    – newGIS
    Commented Mar 31, 2015 at 7:16
  • RasterToOtherFormat_conversion takes a list as input and a workspace as output. I mistook it for Raster_copy. I edited my solution.
    – warrieka
    Commented Mar 31, 2015 at 8:26
  • arcpy.ListRasters("*","JPG") is possibly better in this case, it does not require the user to download glob. First set arcpy.env.workspace to the folder the rasters are in and then returns a list of all the JPEG raster files. Commented Jun 26, 2015 at 3:56

You should iterate through each file in your directory and call the function on each filename:

import os
in_direc  = 'C:\raster_loc'
out_direc = 'C:\converted'
for file in os.listdir(in_direc):
    #check to make sure it's a jpg
    if 'jpg' in file:
        #you need to change the parameters of this function call accordingly
  • 1
    or os.listdir works to :)
    – warrieka
    Commented Mar 30, 2015 at 15:53
  • camdenl,nothing converted with your code and also no error happened. i replace (file,"OtherFormat) with arcpy.RasterToOtherFormat_conversion(in_direc,out_direc,"TIFF")
    – newGIS
    Commented Mar 31, 2015 at 7:24
  • Perhaps reading the method documentation will help next time ;) Commented Mar 31, 2015 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.