Dec-21-2017, 12:25 PM
Hi,
I'm going through the tutorial of the coding app "Mimo" on my iPhone. Part of the tutorial involves trying out the PyCharm Community Edition.
I am using a PC. I have written the following code:
____________________________________________________________________________________________________________________________________
import os
from datetime import datetime
folder = r"C:\Users\JakobS\Desktop\Photos for Python project"
location = input("Photo location:")
files = os.listdir(folder)
for filename in files:
if not
filename.startswith('.'):
file = os.path.join(folder,filename)
m_time = os.path.getmtime(file)
real_time = datetime.fromtimestamp(m_time)
f_time = datetime.strftime(real_time,"%Y%m%d_%H%M%S")
new_filename = f_time + "" + location + ".png"
new_file = os.path.join(folder,new_filename)
os.rename(file,new_file)
____________________________________________________________________________________________________________________________________
I get the following error, though:
____________________________________________________________________________________________________________________________________
C:\Users\JakobS\PycharmProjects\rename_files\venv\Scripts\python.exe C:/Users/JakobS/PycharmProjects/rename_files/renamer.py
File "C:/Users/JakobS/PycharmProjects/rename_files/renamer.py", line 7
if not
^
SyntaxError: invalid syntax
Process finished with exit code 1
____________________________________________________________________________________________________________________________________
Could anybody help me with this?
Thanks in advance
Kasper Mikkelsen
I'm going through the tutorial of the coding app "Mimo" on my iPhone. Part of the tutorial involves trying out the PyCharm Community Edition.
I am using a PC. I have written the following code:
____________________________________________________________________________________________________________________________________
import os
from datetime import datetime
folder = r"C:\Users\JakobS\Desktop\Photos for Python project"
location = input("Photo location:")
files = os.listdir(folder)
for filename in files:
if not
filename.startswith('.'):
file = os.path.join(folder,filename)
m_time = os.path.getmtime(file)
real_time = datetime.fromtimestamp(m_time)
f_time = datetime.strftime(real_time,"%Y%m%d_%H%M%S")
new_filename = f_time + "" + location + ".png"
new_file = os.path.join(folder,new_filename)
os.rename(file,new_file)
____________________________________________________________________________________________________________________________________
I get the following error, though:
____________________________________________________________________________________________________________________________________
C:\Users\JakobS\PycharmProjects\rename_files\venv\Scripts\python.exe C:/Users/JakobS/PycharmProjects/rename_files/renamer.py
File "C:/Users/JakobS/PycharmProjects/rename_files/renamer.py", line 7
if not
^
SyntaxError: invalid syntax
Process finished with exit code 1
____________________________________________________________________________________________________________________________________
Could anybody help me with this?
Thanks in advance
Kasper Mikkelsen