Re: problem with glob in remote directory or os.walk in remote directory in windos
now it is working but i wonder it brings higher number of count as if it counts files in wholes computer can you check in my code and correct me import glob import os file_count=0 for files in glob.glob(r\\192.168.0.45\loader\Files\file_log\v20090225file://192.168.0.45/loader/Files/file_log/v20090225 *): file_count += len(files) print 'Found', file_count, 'files in cwd' the results are Found 435656 files in cwd --which is impossible since files are around six thousands daily. thanks in advance On Thu, Feb 26, 2009 at 5:15 PM, Steve Holden st...@holdenweb.com wrote: lameck kassana wrote: ok my original question is how can count the files of ceratin pattern(eg *.txt) in remote directory .It seems use of glob.glob() for remote directory is not working .Example I want to count the files in following shared folder \\192.168.0.45\files file://192.168.0.45/files how can do it by using glob.glob() glob.glob(r\\houseboy\sholden\*.txt) ['houseboy\\sholden\\pgin1.txt', 'houseboy\\sholden\\POSTGRES.TXT', 'houseboy\\sholden\\gatesquote.txt', 'houseboy\\sholden\\UbuntuWhatNow.txt', 'houseboy\\sholden\\patch001.txt'] glob.glob(r\\192.168.2.200\sholden\*.txt) ['192.168.2.200\\sholden\\pgin1.txt', '192.168.2.200\\sholden\\POSTGRES.TXT', '192.168.2.200\\sholden\\gatesquote.txt', '192.168.2.200\\sholden\\UbuntuWhatNow.txt', '192.168.2.200\\sholden\\patch001.txt'] Working just fine for me. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with glob in remote directory or os.walk in remote directory in windos
En Fri, 27 Feb 2009 07:02:57 -0200, lameck kassana lkass...@gmail.com escribió: now it is working but i wonder it brings higher number of count as if it counts files in wholes computer can you check in my code and correct me import glob import os file_count=0 for files in glob.glob(r\\192.168.0.45\loader\Files\file_log\v20090225file://192.168.0.45/loader/Files/file_log/v20090225 *): Add this line: print files file_count += len(files) print 'Found', file_count, 'files in cwd' the results are Found 435656 files in cwd --which is impossible since files are around six thousands daily. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with glob in remote directory or os.walk in remote directory in windos
At last i did it it was this wrong line file_count += len(files) ---it supposed to be file_count+=1 but thanks for help ya python masters .Steven Holden thanks very very much for your tip about raw string On Fri, Feb 27, 2009 at 12:43 PM, Gabriel Genellina gagsl-...@yahoo.com.arwrote: En Fri, 27 Feb 2009 07:02:57 -0200, lameck kassana lkass...@gmail.com escribió: now it is working but i wonder it brings higher number of count as if it counts files in wholes computer can you check in my code and correct me import glob import os file_count=0 for files in glob.glob(r\\192.168.0.45\loader\Files\file_log\v20090225file:// 192.168.0.45/loader/Files/file_log/v20090225 *): Add this line: print files file_count += len(files) print 'Found', file_count, 'files in cwd' the results are Found 435656 files in cwd --which is impossible since files are around six thousands daily. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with glob in remote directory or os.walk in remote directory in windos
lameck kassana wrote: now it is working but i wonder it brings higher number of count as if it counts files in wholes computer can you check in my code and correct me import glob import os file_count=0 for files in glob.glob(r\\192.168.0.45\loader\Files\file_log\v20090225 file://192.168.0.45/loader/Files/file_log/v20090225*): file_count += len(files) print 'Found', file_count, 'files in cwd' the results are Found 435656 files in cwd --which is impossible since files are around six thousands daily. thanks in advance Please don't use reply all - I subscribe to the list, and will see your posting there. I am pretty sure by now someone has pointed out that you are adding the lengths of the filenames, and what you instead need is file_count = len(glob.glob(...)) regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with glob in remote directory or os.walk in remote directory in windos
lameck kassana wrote: At last i did it it was this wrong line file_count += len(files) ---it supposed to be file_count+=1 but thanks for help ya python masters .Steven Holden thanks very very much for your tip about raw string Lameck: Please note that file_count = 0 for files in (...): file_count += 1 can be *much* more efficiently expressed as file_count = len(...) regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with glob in remote directory or os.walk in remote directory in windos
lameck kassana wrote: i am trying to write script which will count files for remote directory which having certain pattern. Please refrain from repeating questions. When you posted this a reply had already been made to your original posting. Remember, this isn't a paid help desk ... regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with glob in remote directory or os.walk in remote directory in windos
ok my original question is how can count the files of ceratin pattern(eg *.txt) in remote directory .It seems use of glob.glob() for remote directory is not working .Example I want to count the files in following shared folder \\192.168.0.45\files file://192.168.0.45/files how can do it by using glob.glob() On Thu, Feb 26, 2009 at 4:46 PM, Steve Holden st...@holdenweb.com wrote: lameck kassana wrote: i am trying to write script which will count files for remote directory which having certain pattern. Please refrain from repeating questions. When you posted this a reply had already been made to your original posting. Remember, this isn't a paid help desk ... regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with glob in remote directory or os.walk in remote directory in windos
lameck kassana wrote: ok my original question is how can count the files of ceratin pattern(eg *.txt) in remote directory .It seems use of glob.glob() for remote directory is not working .Example I want to count the files in following shared folder \\192.168.0.45\files file://192.168.0.45/files how can do it by using glob.glob() glob.glob(r\\houseboy\sholden\*.txt) ['houseboy\\sholden\\pgin1.txt', 'houseboy\\sholden\\POSTGRES.TXT', 'houseboy\\sholden\\gatesquote.txt', 'houseboy\\sholden\\UbuntuWhatNow.txt', 'houseboy\\sholden\\patch001.txt'] glob.glob(r\\192.168.2.200\sholden\*.txt) ['192.168.2.200\\sholden\\pgin1.txt', '192.168.2.200\\sholden\\POSTGRES.TXT', '192.168.2.200\\sholden\\gatesquote.txt', '192.168.2.200\\sholden\\UbuntuWhatNow.txt', '192.168.2.200\\sholden\\patch001.txt'] Working just fine for me. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list