Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PaulGwamanda/9b56eb04776f053e7a489758f8828857 to your computer and use it in GitHub Desktop.
Save PaulGwamanda/9b56eb04776f053e7a489758f8828857 to your computer and use it in GitHub Desktop.
Create new item for every item found in a list
# ie List is a normal list:
# 104.txt
# 105.txt
# 106.txt
# 107.txt
# 108.txt
# When done with code below should give me 5x files with a .txt extension, ie 104.txt, 105.txt. Can be any file ext.
List = open("64-120/rename.txt")
List2 = (s.strip() for s in List)
# Loop through the list and create a file with item
for item in List2:
open('64-120/%s.txt'%(item,), 'w')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment