Mike's @mgalloy answer is the best way to do this.
The others could have issues depending on your situation (e.g., if you have have a lot of files or need to run this in the Virtual Machine), but certainly work.
Before hashes, this is how I used to do it:
files = ['image1.img', 'image2.img', 'image3.img']
FOR i=0, N_Elements(files)-1 DO BEGIN
varName = File_BaseName(files[i], '.png')
thisImg = Read_Binary(files[i])
(Scope_VarFetch(varName), Level=0, /Enter) = thisImg
ENDFOR
The Scope_VarFetch
is the magic command that creates a variable with a particular name (given as a string), and assigns data to it. You can also retrieve variables in a similar manner.
But, it's much easier to use some of the more modern features of IDL. That same code using hashes and a ForEach?
files = ['image1.img', 'image2.img', 'image3.img']
imgs = Hash()
FOREACH, f, files Do imgs[f] = Read_Binary(files[i])
If order matters, you can use a ordered hash