Apply an operation to each of the files in a directory, producing a new directory of files.

Define a source directory

Define the source directory that contains the files to operate on:

Define a destination directory

Define the destination directory for the processed files, in this case, an automatically created temporary directory:


Make a function to apply to the contents of a file

Define a function to apply to the contents of each file. This function makes a line drawing from an image:

Test the function:

Click for copyable input

Apply the Function to Files in the Source Directory, Putting the Results in the Destination Directory

We will apply the function to the PNG files in the source directory. These are the source files:


Import each source file, apply the function, and export to a file in the destination directory with the same name as the source file:

Verify the Result

Verify the contents of the destination directory:

Click for copyable input