Append directory path to FNs over entire directory structure
by ericlindellnyc from LinuxQuestions.org on (#4QNR1)
I would like each file on my drive to have self-contained information about its proper location, in case it is moved.
Only the 5 deepest subdirectories are needed.
So,
/Volumes/Drive1/ ... /AA/BB/CC/DD/EE/FF/sample.txt
would become
BBCCDDEEFFsample.txt
& located in same directory as original file, i.e.
/Volumes/Drive1/ ... /AA/BB/CC/DD/EE/FF/BBCCDDEEFFsample.txt.
I have googled around to find how to append PWD, but that only works if you're "in" each subdirectory as you traverse.
Help much appreciated.


Only the 5 deepest subdirectories are needed.
So,
/Volumes/Drive1/ ... /AA/BB/CC/DD/EE/FF/sample.txt
would become
BBCCDDEEFFsample.txt
& located in same directory as original file, i.e.
/Volumes/Drive1/ ... /AA/BB/CC/DD/EE/FF/BBCCDDEEFFsample.txt.
I have googled around to find how to append PWD, but that only works if you're "in" each subdirectory as you traverse.
Help much appreciated.