I'm planning to put into my table a column with folder path, so it will be easy to open a folder with needed files in attributes table. Now I'm wondering if I could open not the folder, but all files in it.

It would be great to just get all pdf in directory, no matter how they are named (so I don't have to store filenames anywhere). But the schema is simple: all files have prefix and number from _1 to _7, eg. a_1.pdf, a_2.pdf, a_3.pdf... But sometimes one of those files is missing.

I tried to put all paths to varchar, as string like "C:\a_1.pdf;C:\a_2.pdf(...)" or as array but "open" doesn't work with more than one path. Any suggestions?


You can define a action type "Python" and then use a little python script to open multiple PDFs at once. In this example I have an attribute named 'path' which holds the path information. Be aware that the backslash in the path information in Python must be escaped or use a normal slash (must be c:/test/ or with double backslashes). so the whole thing looks like this:

enter image description here

and the code should be like this:

import os
dir = '[%path%]'
for root, dirs, files in os.walk(dir):
   for fname in files:

I only tested it with QGIS (3.4) for windows.

  • Yeah, it works. I looked at other topics and ended with something like this import os dir = str(r'[%path%]').replace('\\','\\\\') for root, dirs, files in os.walk(dir): for fname in files: os.startfile(dir+"\\\\"+fname) so I can use my column with standard path. Thank you!
    – Krakatau
    Dec 7 '18 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.