Opening a seismic as soon as it is added to a directory

The following script automatically opens a XSection window when a seismic file is added to the C:\Data directory, no user interaction required.

It uses several advanced concepts:

When this script is launched:

  • a watch service is created for the C:\Data directory
  • a new thread is created for that service

In this thread, we wait until the watch service has found a new file.

When a new file is found, we wait until it is fully written to disk.

Then we open it in a XSection window in the Swing thread (a.k.a the event dispatch thread)

You can download this script at the bottom of this page. To execute this script, just drag and drop it into the Python terminal.

In a real world implementation, you might want to:

  • watch for new files in multiple directories, or recursively through the file system hierarchy
  • check that the file is of the right type (ex: Segy)