2👍
✅
You can do the following (treating the path as a string):
'http://my-cdn-path.com/' + '/'.join(i.split('/')[-4:]))
Or, using os.path:
'http://my-cdn-path.com/' + '/'.join(os.path.abspath(i).split(os.sep)[-4:])
👤FMcC
Source:stackexchange.com