1

I am going to using Python to rename some files that are saved in the local Google Drive File Stream. The os.listdir can find all the files in a given folder. But os.rename cannot be performed, because of the error:

"FileNotFoundError: [WinError 3] The system cannot find the path specified: 'G:\\.shortcut-targets-by-id\\17HXYw7EIOuzCUdeM0QulV-aWGAuZug6s\\....'.

The file actually exists. This is a false alarming.

I also tried doing the same thing in Matlab, and got a similar error "Cannot find the specified file:....".

Is there any solution to achieve this, without moving the files in the google file stream to a local folder?

jwm
  • 4,832
  • 10
  • 46
  • 78
  • Could you try getting the path of the file you wish to rename using this `os.path.abspath(FILE)` and then try renaming it with the returned path? – yudhiesh Jan 23 '21 at 06:35
  • This does not help either. In os.rename, I did use the absolute path as the input – jwm Jan 23 '21 at 17:39

1 Answers1

0

In my case i have a code that delete a file on a folder (a shortcut in my drive through google file stream), later i take a file from desktop folder and move to the destination folder.This is the syntax that i use:

import shutil, os  
path_excel = r"C:\Users\user\Downloads\file.xls"
dest_folder = 'G:\.shortcut-targets-by-id\\id\\folder\folder1'
path_reporte_original = r'G:\.shortcut-targets-by-id\\folder\\folder\folder\\file.xls'
try:
    os.remove(path_reporte_original)
    print("Archivo eliminado")
except:
    print("Archivo ya había sido eliminado o no existente")

files = [path_excel]
for f in files:
    shutil.move(f, dest_folder)

print ("Carga exitosa...")

Maybe you can use a similar syntax for your purpose. Tell me if is useful or maybe we will talk later. Greetings!