Capturing a document's folder name and storing as a variable

I am looking to capture a document's folder location (just the name of that folder, not the full path) and store it as a variable on it's datacard so that it can be used for the location of that document's PDF output in a mirrored set of folders.  I would like this variable to update when the file is moved to a different folder, as well.  Any thoughts?

SolidworksSolidworks Pdm enterprise Pdm