Created
March 5, 2020 16:14
-
-
Save s-hiiragi/c6b0c54c3bb8e330197a1f80d612047f to your computer and use it in GitHub Desktop.
Convert long file names to short file names in current directory
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
import os | |
from ctypes import windll, create_unicode_buffer | |
dll = windll.LoadLibrary('kernel32.dll') | |
for longname in os.listdir('.'): | |
shortname = create_unicode_buffer(16) | |
dll.GetShortPathNameW(longname, shortname, 16) | |
if shortname.value.lower().endswith('2.csv'): | |
print('from:', longname) | |
print('to :', shortname.value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment