Skip to content

Instantly share code, notes, and snippets.

@agu3rra
Created March 20, 2020 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agu3rra/4d9baa1088191c6f582337c1e5f9f01b to your computer and use it in GitHub Desktop.
Save agu3rra/4d9baa1088191c6f582337c1e5f9f01b to your computer and use it in GitHub Desktop.
Python script to ensure Windows PATH has distinct values
# Not sure why some of them appear repeated but sometimes they do.
# Since there is a limit of 1024 chars to the SETX command, this sometimes comes in handy.
import os
path = os.environ['PATH']
elements = path.split(';')
elements = set(elements)
new_path = ''
for item in elements:
new_path+='{};'.format(item)
with open('newpath.txt', 'w') as output:
output.write(new_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment