Usually, we insert a small number of images in a notebook using the method shown in the figure. If there are many images to insert, what method can be used to insert all image files in a certain folder at once?
One idea would be to loop over the list of filenames in FileNames[All, dir] and use one of the following to write into the notebook:
CellPrint[ExpressionCell[Import[filename], "Input"]]
NotebookWrite[EvaluationNotebook[],
Cell[BoxData[Import[filename] // MakeBoxes[#, StandardForm] &], "Input"]]
And it does not have to be in "Input" style, but that’s what the menu command does.
One could also use
CopyToClipboard[DocumentNotebook[listOfImageCells]]
where listOfImageCells is computed from looping through filenames and has the form
{ExpressionCell[img1, "Input"], ExpressionCell[img2, "Input"],…}
After copy, then paste. It should paste each cell separately if the insertion point is between cells. Maybe beware the total size of the images.
Assuming they’re all of the same file extension, you can use the * character to get all the files of a given extension in a directory. For example if they were PNG images
Import[FILEPATH, "*.png"]
Be careful to note that this will extract all PNG images at any level, even within subdirectories of FILEPATH. If you only want files explicitly in FILEPATH you can append *.png to the FILEPATH:
Import[FileNameJoin[{FILEPATH, "*.png"}]]
