Python script won't rename files when not run in PyCharm

Viewed 37

I am trying to create an exe file that will allow a user drag a folder into the application then rename all the files in that directory to begin with user input. I had this working in PyCharm but now it wont when I try to run from python 3.10 on my win 10 desktop.

I have tried with and without the .strip method to remove the quotation marks from dragging a folder in. I have also tried running just the .py as well as creating a .exe with pyinstaller

Where am I going wrong?

import os

def main():
    path = input('Drag folder to rename here: ')
    path = path.strip('"')
    jNum = input('Prefix all files in folder with: ')

    if not(jNum.endswith(" ")):
        jNum = "{} ".format(jNum)

    for filename in os.listdir(path):
        os.rename(os.path.join(path,filename), os.path.join(path, jNum+filename))

main()
0 Answers
Related