My original code is here. I made some changes to it based on your suggestions, but then I lost my flash drive and had to redo it. I have a suspicion that my second version was better than this one, so could you all help me out one more time?
import os, shutil, zipfile def subtractname(path): newpath = str() path = path.split("\\") path.pop() for x in range(len(path) - 1): newpath += (path[x] + "\\") newpath += path[len(path) - 1] return newpath def pathtoname(path): path = path.split("\\") newpath = path[len(path) - 1] newpath = newpath[:-4] return(newpath) def makepath(path): try: os.makedirs(path) except FileExistsError: shutil.rmtree(path) os.makedirs(path) def getscds(targetfolder): global scdlist filelist = os.listdir(targetfolder) scdlist =  for file in filelist: if '.scd' in file: scdlist.append(os.path.join(targetfolder, file)) return scdlist def unzip(file, target): modscd = zipfile.ZipFile(file) makepath(target) modscd.extractall(target) def checkdirs(target): isfile = 0 targetlist = os.listdir(target) for files in targetlist: if not os.path.isfile(files): isfile = isfile + 1 if isfile == len(os.listdir(target)): return False else: return True def install(folderlist): newpathlist =  for folder in folderlist: pathlist = getscds(folder) for path in pathlist: newpath = os.path.join(subtractname(path), ("f_" + pathtoname(path))) newpathlist.append(newpath) unzip(path, newpath) if checkdirs(newpath): shutil.copy(path, r"C:\Program Files (x86)\Steam\steamapps\common\supreme commander 2\gamedata") newpathlist.remove(newpath) return newpathlist a = input() b = [a] install(install(install(b)))
A note: this code SHOULD actually work if you run it, but I haven't incorporated error handling yet.
I know that the last three lines can be condensed into one, but aside from that is there anything that could be improved here? I'm not really looking for naming conventions or comments, but I'm fine with it if you want to throw them in along with some more practical suggestions.
EDIT: I just tried running this on a friend's computer, and it may not work after all. Ideas?