title: How to rename a file with Python?
body: <p>I am triying changing the name of file using Python but the name does not change. 
  The program has to take a photo, save it, copy it to a server, change the name of copied photo and change the name of original photo.
  So, first of all I define a variable which is going to be a exact date and time. After that, I take a photo and save it like imagen.jpg
  Following, I copy imagen.jpg to other path (server path), and try change his name to the variable wich I definied before. But the name does not change and the file is removed. 
  After that I change  the name of original photo with the same function and the name is changed....I dont know why the copied photo dont change his name.
  Here's the code:</p>
  
  <pre><code>import shutil
  import picamera
  import os
  fecha = time.strftime("%c")  # En esta variable se guarda la fecha actual y la hora para renombrar la foto guardada          
  camera.capture('/home/pi/Desktop/RaspAlarm/imagen.jpg')
  print("Capturando foto")
  time.sleep(5)
  print("Copiando foto al servidor")
  shutil.copy("/home/pi/Desktop/RaspAlarm/imagen.jpg", "/var/www/html/RaspAlarm/Fotos")
  time.sleep(1)
  os.listdir("/var/www/html/RaspAlarm/Fotos")
  os.rename ("/var/www/html/RaspAlarm/Fotos/imagen.jpg", fecha)
  print("Cambiando nombre al archivo")
  os.rename ("/home/pi/Desktop/RaspAlarm/imagen.jpg", fecha)
  time.sleep(1)
  print("Foto guardada")
  </code></pre>
  
  <p>Could you help me? Thank you</p>