Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - Re: i have problem with glob.glob() in remotely directory

 
Thread Tools Search this Thread
Old 02-26-2009, 09:16 AM   #1
Default Re: i have problem with glob.glob() in remotely directory


On Thu, Feb 26, 2009 at 1:05 AM, lameck kassana <> wrote:
> hey i want to count number of files in remote computer
>
> example of my code is
>
> import glob
> import os
> import time
> from datetime import date
> today=date.today()
> dir_count, file_count=0, 0
>
> for files in glob.glob('\\192.168.0.45\files\*.txt'):


Remember that *backslash is the escape character* in Python, so you
need to double-up your backslashes in the string literal (or just use
forward slashes instead, Windows doesn't seem to care for Python in
most cases). Right now, the path really only starts with 1 backslash
and it has a formfeed character in it (\f), so it's obviously invalid;
thus, your problem.

So you want:
#looks ugly, doesn't it?
for files in glob.glob('\\\\192.168.0.45\\files\\*.txt'):

Or:
#will probably but not assuredly work
for files in glob.glob('//192.168.0.45/files/*.txt'):

Cheers,
Chris

--
Follow the path of the Iguana...
http://rebertia.com


Chris Rebert
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Active Directory Problem / Sync and Group Policy. keithalmli General Help Related Topics 0 08-11-2007 03:18 AM
Dial Up Problem smackedass A+ Certification 3 02-02-2007 11:59 PM
Re: Virus Problem ** Help!** David BlandIII A+ Certification 1 03-02-2004 06:00 PM
Re: Serious Computer Problem hootnholler A+ Certification 1 11-24-2003 12:18 PM
Re: Serious Computer Problem Bret A+ Certification 0 11-19-2003 12:51 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46