Google Help Any Programmers?

We need need to update our student Google Profile Photos like we do in Blackbaud, but Google does not have a bulk option. I found an App to connect, but first I need to change the name of the photo files to the student's email address. I found a script to run on my MAC in Terminal to bulk change the name of my files from a CSV, but when I run it I get an error this error:

zsh: parse error near `)'

I changed "George" to my username. What am I missing? I do not know how to write programming. THANK YOU IN ADVANCE!!!!

os.chdir('/Users/George/Desktop/untitled folder')

# Rename from name in col 1 to name in col 2 in CSV File)

with open('/Users/George/Desktop/Book1.csv') as f:

lines = csv.reader(f)

for line in lines:

try:

os.rename(line[0], line[1])

except:

print(line[0] + ': File not found')

Comments

  • @Josceline Reardon Do you have this in a .py file? You can create a plain text file in TextEdit and paste the following code below, update the username, and save it as something like changeFilename.py to your desktop.

    Once you have the file set up, you can run it in Terminal by typing:

    cd ~/Desktop

    python changeFilename.py

  • @Troy Burki
    Thank you so much for reaching out I have absolutely no programming experience, just trying to muddle my way through to get this figured out.

    So I typed what you provided in Text Editor, changed the USERNAME to “jreardon” and then renamed it “changefilename.py” (I read I could just change the txt to the python py extension).

    Terminal asked for access to my desktop, I approved and then I got this error below (this was further than I got before!!)

    I uploaded the txt file (it wouldn't let me upload .py) and also my test csv file if you have time to take look. Thank you so so much! Happy Friday!

    jreardon@AirofJoeReardon ~ % cd ~/Desktop

    python changeFilename.py

    File "changeFilename.py", line 1

    1 import os

    ^

    SyntaxError: invalid syntax

    jreardon@AirofJoeReardon Desktop %

    changefilename.txt

    Book1.csv

    UPDATE:

    SO I did the close function and then pasted in the function and it seems like it searched for the file. This is the new error.

    jreardon@AirofJoeReardon ~ % exit()

    function> cd ~/Desktop

    python changeFilename.py

    /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'changeFilename.py': [Errno 2] No such file or directory

    jreardon@AirofJoeReardon ~ %

  • @Josceline Reardon Hi Josceline, not a problem. From the responses you included, it looks like when you copied the code it also copied the line numbers (first line should just be import os instead of 1 import os). It looks like you have Python 2.7 so I've modified the code to work with that version. If you click view raw in the bottom right corner it will give you just the code to copy. Once you've pasted it in to your changeFilename.txt file and changed the file extension to .py you can open a new Terminal and enter those two commands again.