I'm trying to write a small program that allows the user to click a button to select files, type in a stock number, and then click a button to rename those files.

This is what I've come up with so far:

```
import os
from tkinter import *
from tkinter import ttk
from tkinter.filedialog import askopenfilenames

root = Tk()
root.title("Photo Renamer")
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)

directory = ''
arrayOfFiles = []
stockNum = 0

def getStockNumber():
    stockNum = stockNumber.get()

def selectFiles():
    selectedFiles = askopenfilenames()
    # Switch our files from a tuple to an array.
    # arrayOfFiles = []
    for i in selectedFiles:
        arrayOfFiles.append(i)
    return arrayOfFiles

def rename(array): # array will be arrayOfFiles
    # Separate file names from the whole file path.
    fileNames = []
    for i in range(len(array)):
        fileNames.append(os.path.basename(i))

    count = 1
    directory = os.path.dirname(array[1])
    for file in directory:
        oldFileName = '%s/%s' % (directory, file)
        newFileName = '%s/gma%d_%d.jpg' % (directory, stockNum, count)
        os.rename(oldFileName, newFileName)
        count += 1

# "Stock Number" label
ttk.Label(mainframe, text="Stock Number: ").grid(column=1, row=1, sticky=W)

# Entry box
stockNumber = ttk.Entry(mainframe, width=7)
stockNumber.grid(column=2, row=1, sticky=(W, E))

# "Select Files" button
ttk.Button(mainframe, text="Select Files", command=selectFiles).grid(column=1, row=2, sticky=(W, E))

# "Number of Files" label
ttk.Label(mainframe, text="Number of Files: ").grid(column=1, row=3, sticky=W)

# "Rename" button
ttk.Button(mainframe, text="Rename", command= lambda: rename(arrayOfFiles)).grid(column=3, row=3, sticky=(W, E)) # command=rename

for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)
stockNumber.focus()

root.mainloop()

```

I can select the files, and type in the stock number, but when I click the rename button, it gives me this error in the console:

```
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\...\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 1549, in __call__
    return self.func(*args)
  File "C:/Users/.../Desktop/Python/gui.py", line 56, in <lambda>
    ttk.Button(mainframe, text="Rename", command= lambda: rename(arrayOfFiles)).grid(column=3, row=3, sticky=(W, E)) # command=rename
  File "C:/Users/.../Desktop/Python/gui.py", line 32, in rename
    fileNames.append(os.path.basename(i))
  File "C:\Users\...\AppData\Local\Programs\Python\Python35-32\lib\ntpath.py", line 232, in basename
    return split(p)[1]
  File "C:\Users\...\AppData\Local\Programs\Python\Python35-32\lib\ntpath.py", line 204, in split
    d, p = splitdrive(p)
  File "C:\Users\...\AppData\Local\Programs\Python\Python35-32\lib\ntpath.py", line 139, in splitdrive
    if len(p) >= 2:
TypeError: object of type 'int' has no len()

```