To cut the memory usage to half, in this case you can set the $HistoryLength to 0 which forces Mathematica to not keep copies of the data in the Out list.
For increasing the Import speed, you can save all the images in a multipage tiff file and then import them at once which is a lot faster.
$HistoryLength = 0
You may also use the ParallelMap[] function which uses multiple cores (depending on your license) and is usually faster :
Impimg = ParallelMap[Import[#] &, FileNames["*.bmp"]];
Either removing the "Data" format argument or using "JPEG" instead should do it.
Here is a short example based on the original code.
imgdir = FileNameJoin[{NotebookDirectory[], "Flow pic"}];
(*Export three images for testing purpose*)
SeedRandom[42];
images = ExampleData /@ RandomChoice[ExampleData["TestImage"], 3]
Export[FileNameJoin[{imgdir, "le-" <> ToString[#] <> ".jpg"}],
images[[#]], "JPEG"] & /@ Range[3];
FileSystemMap[FileSize, imgdir]
(*Output*)

(*Using Import function with "JPEG" fmt argument*)
imagesA = Import[FileNameJoin[{imgdir, "le-" <> ToString[#] <> ".jpg"}], "JPEG"] & /@ {3, 2, 1};
Map[ImageTake[#, {50, 630}, {499, 600}] &, Map[ImageResize[#, {900, 650}] &, imagesA]]
(*Using Import function w/o fmt argument*)
imagesB = Import[FileNameJoin[{imgdir, "le-" <> ToString[#] <> ".jpg"}]] & /@ {3, 2, 1};
Map[ImageTake[#, {50, 630}, {499, 600}] &, Map[ImageResize[#, {900, 650}] &, imagesB]]
(*Output*)

Try this....
Test images

imgdir = FileNameJoin[{NotebookDirectory[], "Flow pic"}]
imgdata = Import[FileNameJoin[{imgdir,"le-" <> ToString[#] <> ".jpg"}]] & /@ {3, 2, 1};
image = ImageTake[#, {50, 630}, {499, 600}] & /@ ImageResize[#, {900, 650}] & /@ imgdata

images = Image /@ ArrayReshape[Import[file, "UnsignedInteger16"], {100, 256, 320}];
After some dig in version 13, I found a package that can do this indeed. And I have tried Canon and Sony, so far so good.
<< ImageFileTools`
Here is a function ImageFileTools`Raw`RawGet, and its usage is:
? ImageFileTools`Raw`RawGet

Usage

Import[FileNameJoin[{"Path", "To", "Directory", "*.jpeg"}], "JPEG"] is undocumented but will work (for now, subject to change).
I recommend perhaps FileSystemMap for this task. Simply Import[#, "JPEG"] & /@ FileNames["/Path/To/Directory/*.jpeg"] will work just fine as well.
afaik. there is no easier way than doing
images = {}
names = FileNames[pattern,{directory}]
Do[AppendTo[images = Import[fileName]], {fileName, names}]
with
pattern = "*.png"
directory = "YourDirectoryName"
The code is untested but should work. Sadly i cannot easily test the code lacking such directory.
code from my old question (modified): DumpSave'ing while lengthy program runs
Make your filenames unambiguously parsable, e.g. by consistently using some delimeters like underscores or something. A typical file name can look like "Electric_B_3.png". EDIT If you have no control over the file names, use string patterns as described by other answers, but in the long-term you may benefit from creating your own robust naming scheme END EDIT
Then write a function that would parse a single file name, something like:
fileNameParse[fname_String, delim_String: "_"] :=
StringSplit[FileBaseName[fname], delim]
Then, Map it on FileNames["*.png", {your-dir}].
Finally, apply your importOne on the level one:
importOne@@@Map[fileNameParse, FileNames["*.png", {your-dir}]]
Since you have the result of Map available as well, you can regroup them any way you want. You can, for example, Map a function {#, importOne@@#}&, rather than just using importOne@@@.... Then, you could use GatherBy or any other means to regroup and collect your images according to the parts of their filenames.
EDIT
Here is a self-contained example ( I use text files, but this doesn't matter):
ClearAll[fileNameParse, fileNameMake, importOne, $dir];
fileNameParse[fname_String, delim_String: "_"] :=
StringSplit[FileBaseName[fname], delim];
fileNameMake[pieces_List, delim_String: "_", ext_String: ".txt"] :=
StringJoin[Append[Riffle[pieces, "_"], ".txt"]];
importOne[set_, cat_, num_, dir_: $dir] :=
Import[FileNameJoin[{dir, fileNameMake[{set, cat, num}]}]];
We now create a temporary directory:
$dir = FileNameJoin[{$TemporaryDirectory, "ImportTest"}];
If[! FileExistsQ[$dir], CreateDirectory[$dir]];
Create sample files:
MapIndexed[
Export[#, "Test" <> ToString[#2], "Text"] &,
Flatten[
Outer[
FileNameJoin[{$dir, fileNameMake[{##}]}] &,
{"Electric"}, {"A", "B", "C"}, {"1", "2", "3"}
]]];
import them:
imported = Map[{#, importOne @@ #} &, fileNameParse /@ FileNames["*.txt", {$dir}]]
(*
==>
{{{"Electric", "A", "1"}, "Test{1}"}, {{"Electric", "A", "2"}, "Test{2}"},
{{"Electric", "A", "3"}, "Test{3}"}, {{"Electric", "B", "1"}, "Test{4}"},
{{"Electric", "B", "2"}, "Test{5}"}, {{"Electric", "B", "3"}, "Test{6}"},
{{"Electric", "C", "1"}, "Test{7}"}, {{"Electric", "C", "2"}, "Test{8}"},
{{"Electric", "C", "3"}, "Test{9}"}
}
*)
You can now, for example, group them according to whatever parts of their file names you wish:
GatherBy[imported , #[[1, 2]] &][[1]]
(*
==>
{{{"Electric", "A", "1"}, "Test{1}"}, {{"Electric", "A", "2"}, "Test{2}"},
{{"Electric", "A", "3"}, "Test{3}"}}
*)
Here is one approach. First set your working directory with SetDirectory, then:
names = FileNames["*.png"];
groups = GatherBy[names, StringTake[#, {-6}] &];
Evaluate[
electric[StringTake[#, {-6}]] & /@ groups[[All, 1]]
] = Map[Import[#] ~ImageResize~ 128 &, groups, {2}];
Now access image lists like:
electric["B"]
This relies on manually picking a string position to index by, here {-6}. Leonid's method would be more robust for future naming.
SetDirectory["c:\\users\\rasher\\downloads\\"];
images = FileNames["*.jpg"];
count = 1
Do[imagevar[count++] = Import[image], {image, images}]
Images will be in imagevar[1], imagevar[2]... so you can easily index into them.
Obviously, change directory / filenames to suit.
If you have numbered or desired variable names in mind (acknowledging there are number padding issues for large numbers) you could use. Assuming you have set working directory as per rasher:
images = FileNames["*.jpg"];
MapThread[
Set[#1, #2] &, {ToExpression /@
Table["img" <>
ToString@NumberForm[j, 3, NumberPadding -> {"0", ""}], {j,Length[images]}],
img}];
In this case img0001 is set to images[[1]], img0002 is set to images[[2]],...
However, using an array (as per rasher) will be much easier to deal with and refer to for all but the smallest sets. Otherwise just import the image files into one variable and choose relevant parts of interest.