Re: Number of files in folder problem

Robert Billing <[email protected]> Tue, 14 Jul 2020 12:30:28 +0100
Newsgroups gmane.comp.multimedia.gphoto.user
Message-ID <[email protected]>
Antonio,

I suspect that the zero is the success completion code. You need to 
capture stdout from the command and convert it to an integer.

https://docs.python.org/3/library/subprocess.html

Robert


On 14/07/2020 10:48, Antonio Cuni wrote:
> Hello Erturul,
> you are not showing the full script, so it's hard to help.
> Most likely, you are executing the command using os.system or 
> subprocess.<something>. In that case, the return value you get is not 
> the number of files but the exit code of the command (where 0 means 
> "success"). But it's hard to say without seeing the relevant code.
>
>
> On Sun, Jul 12, 2020 at 4:33 PM Erturul Sinan <[email protected] 
> <mailto:[email protected]>> wrote:
>
>     Ladies and Genlemen,
>
>     first of all, sorry for the disturbance.
>
>     I have one question and I hope there is someone out there who can
>     give me an answer.
>
>     I am using the following command winthin a python script to filnd
>     out how many in´mages are still on the SD-Card of the camera.
>
>     /filesInFolder   = ["gphoto2", "--folder",
>     "/store_00010001/DCIM/100NCD90", "--num-files"]/
>
>     This command works fine and I get as an aswer "Number of files in
>     folder '/store_001001/DCIM/100NCD90': 4"
>
>     Since the command is assigned to a variable (/filesInFolder) /and
>     when I try to print out he content of the variable with
>
>     /print("Num Files = ", filesInFolder)/
>
>     I get the message "Num Files = 0" . I cannot get access to the
>     correct number of 4. How can I do that?
>
>     Now my question is: How can I get access to the correct number of
>     files (4) and assign it to a variable
>     to get it printed out or to process it in further actions?
>
>     Because 0 (zero) is definitive the wrong number.
>
>     Thank you for your help. H A N D
>
>     --
>     Kind regards
>
>
>     Erturul SINAN
>     SinSoft - CSV & IT-Management
>
>     Biebricher Allee 11
>     D-65187 Wiesbaden
>     GERMANY
>
>     Mobile:	+49 - (0)178 - 400 97 55
>     Mailto:	[email protected]  <mailto:[email protected]>
>
>     Dissemination, distribution or copying of this e-mail or the information herein by anyone other than the intended recipient,
>     or an employee or agent of a system responsible for delivering the message to the intended recipient, is prohibited.
>
>     If you are not the intended recipient, please inform the sender and delete all copies and attachments.
>
>     Thank you for your cooperation.
>
>     _______________________________________________
>     Gphoto-user mailing list
>     [email protected]
>     <mailto:[email protected]>
>     https://lists.sourceforge.net/lists/listinfo/gphoto-user
>
>
>
> _______________________________________________
> Gphoto-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/gphoto-user

-- 
Tanglewood Algorithms Ltd
Software Engineering Consultancy
42, Fuller Way,
Andover
SP11 6UJ
United Kingdom

Phone  (+44)-1264-316438
Mobile (+44)-7770-902246

_______________________________________________
Gphoto-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gphoto-user