[Answered ]-How to remove specific directory names from path list

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

Leave a comment