Link to home
Start Free TrialLog in
Avatar of m_travis
m_travisFlag for United States of America

asked on

File in folder on Windows network share using python

For this question lets say the network share is \\192.168.1.1\d$\testfolder\
preferred method: Would like to store all the file names in a python list\
other option: Store all the file names to an output.txt file in c:\resultsfolder\

I am using python 3.4 due to getting the script to integrate with tkinter.
ASKER CERTIFIED SOLUTION
Avatar of gelonida
gelonida
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of m_travis

ASKER

Thank you, worked perfectly.

What is the r for?
if you don't use the r you had to escape every backslash which is quite tedious

example:
r"\\192.168.1.1\d$\testfolder"

Open in new window

is equivalent to
"\\\\192.168.1.1\\d$\\testfolder"

Open in new window

which is less readable and more error prone


There is only one exection (in which I fell immediately, when I heard first about the r prefix.

If the last character of a string is a \ , then you have still to escape it.

so
r"c:\"

Open in new window

is invalid
you had to type
r"C:\\"

Open in new window

Thank you for the explanation. I also posted the following python question that you might be able to help.

Other python question