'Python symlink FileExistsError
I want to read out one folder and create symlinks of this folder in an other folder, but I get an FileExistsError: [WinError 183] file can not be created if it allready exists: 'C:\Users\Dag\Desktop\aaa\0_Data\abc' -> 'C:\Users\Dag\Desktop\aaa\3_Docs\docs'
import os
import tkinter as tk
from tkinter import filedialog
root = tk.Tk()
root.withdraw()
rootDir = filedialog.askdirectory(parent=root, initialdir="/",
title='Select a root directory')
destDir = filedialog.askdirectory(parent=root, initialdir="/",
title='Select a destination directory')
subfolder = ''
subfolderRoot = []
i = 0
for item in os.listdir(os.path.normpath(destDir + "/")):
subfolder = item
i = i + 1
print(subfolder)
print(i)
for item in os.listdir(os.path.normpath(rootDir + "/")):
if os.path.isdir(os.path.join(rootDir, item)):
source = os.path.normpath(rootDir + "/" + item)
link_name = os.path.normpath(destDir + '/' + subfolder + '/')
os.symlink(source, link_name)
print("dest: " + link_name)
print("source: " + source)
print(subfolder)
What do I wrong here?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
