Új hozzászólás Aktív témák

  • Hege1234

    addikt

    sziasztok!

    a cél az lenne, hogy ha már létezik ott egy ugyan olyan mappa az abban lévő fájlt csak simán írja felűl, de a shutil már az ugyan olyan mappára kiakad..
    a fájlig el se tudtam még jutni

    hogyan lehetne megoldani?

    def move_or_copy(src, dest):
    if os.path.isdir(src):
    if not os.path.exists(dest):
    shutil.copytree(src, dest)
    print(f"A mappa áthelyezve: {os.path.abspath(dest)}")
    else:
    for src_item in os.listdir(src):
    src_file = os.path.join(src, src_item)
    dest_file = os.path.join(dest, src_item)
    move_or_copy(src_file, dest_file)
    elif os.path.isfile(src):
    if os.path.exists(dest):
    print(f"A fájl '{os.path.abspath(dest)}' már létezik, felülírás...")
    shutil.move(src, dest)
    print(f"A fájl áthelyezve: {os.path.abspath(dest)}")

    src_path = ripper_dir + '\\Downloads\\'
    trg_path = dirPath + '.\\Downloads\\befejezett\\Prime\\!VT HD!\\Series'

    for src_item in os.listdir(src_path):
    src = os.path.join(src_path, src_item)
    dest = os.path.join(trg_path, src_item)
    move_or_copy(src, dest)

    error:

    Traceback (most recent call last):
    File "C:\Users\@\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1885, in __call__
    return self.func(*args)
    File "I:\python v3\main.py", line 59820, in vt_amzn_Series_hd_01
    shutil.move(src_file, dest)
    File "C:\Users\@\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 801, in move
    raise Error("Destination path '%s' already exists" % real_dst)
    shutil.Error: Destination path 'I:\python v3\Downloads\befejezett\Prime\!VT HD!\Series\Odaat.S07.1080p.AMZN.WEB-DL.DDP2.0.H.264-\Odaat.S07.1080p.AMZN.WEB-DL.DDP2.0.H.264-' already exists

Új hozzászólás Aktív témák