I am trying to write a DigitalMicrograph script which opens all images containing a specific string in the file name.
I know how I can open an image using OpenImage( filename )
and I have seen in the documentation that a command GetFilesInDirectory()
exists, which seems to be what I need. However, I do not understand how I can use this command. Can somebody give me a code snippet demonstrating this, please?
The command
GetFilesInDirectory()
gives you a TagList of all files / subfolders in a given directory. This is shown in the following example:This script will show you the resulting TagGroup in a browser window like the one below. Each list entry is itself a TagGroup which contains a single tag "Name". This tag contains the file or folder name. You can use the command to either give you only files, only subfolders, or both.
Once you have the TagGroup of all entries, you process is like any other TagGroup in DigitalMicrograph. For example, you can browse the list to read out the strings and simple print them to the results window like this: