I am trying to rename a XXXX.out file into a XXXX.txt file for it to be read into the rest of my very large model that does other things. This ".out" really is a simple ".csv" file and once I have the extension on it renamed I do many great things to it. I have hundreds of them and they will be continued to be made in ".out" files.
So far the only way I've come up with doing this is Parse Path, but I can't figure out how to combine the end results into something that can get fed into the rest of my model.
I am pretty new to model building and python.
I've attached the screen shot of this very small portion of the model I have so far.
From tikinter import Tk From tkFileDialog import askopenfilename Import os, sys, tempfile, shutil Tk().withdraw() filename = askopenfilename(filetypes = ((“My Name”, “.out”), (“All files”, “*.*”),)) print (filename) #checking my work TempFolder = tempfile.mkdtemp() Print TempFolder #check my work Shut.copy2(filename, TempFolder) For filesinfolder in os.listdir(TempFolder): Infilename = os.path.join(TempFolder, filesinfolder) If not os.path.isfile(infilename): continue Oldbase = os.path.splitext(filesinfolder) Newname = infilename.replace (‘.out’, ‘.txt’) Output = os.rename(infilename, newname)
Print (newname) #checking my work and this give the whole path including the newly renamed text file.