Skip to content

Instantly share code, notes, and snippets.

@aonurdemir
Last active June 24, 2020 22:26
Show Gist options
  • Save aonurdemir/b5f37ed04ad14fd5ebaef27beb46111d to your computer and use it in GitHub Desktop.
Save aonurdemir/b5f37ed04ad14fd5ebaef27beb46111d to your computer and use it in GitHub Desktop.
Python file operations
import os
from os import listdir
from os.path import isfile, join
from shutil import copy2
if __name__ == '__main__':
mypath = u'C:\\Users\\Onur\\Downloads\\Twitch Sesler-20200624T185904Z-001\\Twitch Sesler\\lowercase'
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
# try:
# os.mkdir(mypath+"\\lowercase")
# except OSError:
# print("Creation of the directory %s failed" % mypath)
# else:
# print("Successfully created the directory %s " % mypath)
f = open("map.txt", "w",encoding="utf-8")
for file in onlyfiles:
#copy2(mypath+"\\"+file, mypath+"\\lowercase\\"+file.lower())
f.write("'"+file.split('.')[0]+"',\n")
f.close()
print("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment