I have a shapefile with two columns with links to directory and/or file and NULL Each record has a columns 'NAME. Something like this
... NAME HOTLINK1 HOTLINK2 ... name1 C:\...\directory1 C:\...\directory6\file ... name2 C:\...\directory2 NULL ... name3 C:\...\directory5\file C:\...\directory ... name4 NULL NULL
whit the code below I can create a folder for every record in "NAME" if not exist:
import os layer = iface.activeLayer() idx = layer.fieldNameIndex('NAME') path = "path/to/directory" for feat in layer.getFeatures(): attrs = feat.attributes() if not os.path.exists(path + attrs[idx]): os.makedirs(path + attrs[idx])
Now I would need develop this code so as to copy the entire contents of the directory (subdirectories included) and the file from HOTLINK1 and HOTLINK2 to new directory 'NAME'.
if HOTLINK is a directory >>> copy the entire contents of the directory (subdirectories included)
if HOtLINK is a file >>> copy the file
if is NULL >> pass.