Python Forum
Dynamic File Name to a shared folder with open command in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic File Name to a shared folder with open command in python
#3
files = glob.glob(r"\\192.168.1.4\aaaa\*.xml")
This could not work. It's a share over network and not mounted as a real file system.

You can mount the share on Linux and work with Python on the mountpoint.
You can mount the share on Windows and work with the mounted drive.

You can also use a nice wrapper for file systems:
# python3 -m pip install fs fs.smbfs
# read the docs: https://docs.pyfilesystem.org/en/latest/index.html
import fs


with fs.open_fs("smb://USERNAME:[email protected]") as samba_share:
    # samba_share is:
    # BoundGlobber(pattern, path="/", namespaces=None, case_sensitive=True, exclude_dirs=None)
    # https://docs.pyfilesystem.org/en/latest/globbing.html#matching-files-and-directories
    samba_share.glob("**/*.xml", "/aaaa").remove()
Gribouillis likes this post
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
RE: Dynamic File Name to a shared folder with open command in python - by DeaD_EyE - Jan-06-2022, 12:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Delete file with read-only permission, but write permission to parent folder cubei 6 22,449 Jun-01-2024, 07:22 AM
Last Post: Eleanorreo
  How to Randomly Print a Quote From a Text File When User Types a Command on Main Menu BillKochman 13 1,537 Apr-24-2024, 05:47 AM
Last Post: Bronjer
Question How to add Python folder in Windows Registry ? Touktouk 1 421 Feb-20-2024, 01:04 PM
Last Post: DeaD_EyE
  Open/save file on Android frohr 0 450 Jan-24-2024, 06:28 PM
Last Post: frohr
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 745 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  file open "file not found error" shanoger 8 1,567 Dec-14-2023, 08:03 AM
Last Post: shanoger
  Reading a file name fron a folder on my desktop Fiona 4 1,107 Aug-23-2023, 11:11 AM
Last Post: Axel_Erfurt
  How can i combine these two functions so i only open the file once? cubangt 4 1,089 Aug-14-2023, 05:04 PM
Last Post: snippsat
  how do I open two instances of visual studio code with the same folder? SuchUmami 3 1,115 Jun-26-2023, 09:40 AM
Last Post: snippsat
  I cannot able open a file in python ? ted 5 4,020 Feb-11-2023, 02:38 AM
Last Post: ted

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020