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:

Out[2]=

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:

In[4]:=
Click for copyable input
Out[4]=

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:

Out[5]=

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:

In[7]:=
Click for copyable input
Out[7]=