Created
March 20, 2020 10:10
-
-
Save agu3rra/4d9baa1088191c6f582337c1e5f9f01b to your computer and use it in GitHub Desktop.
Python script to ensure Windows PATH has distinct values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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