Re: Number of files in folder problem
Michael Mayer <[email protected]> Tue, 14 Jul 2020 13:53:50 +0100 (BST)
| Newsgroups | gmane.comp.multimedia.gphoto.user |
|---|---|
| Message-ID | <[email protected]> |
Hello Erturul, your issue seems to be mostly related to a string manipulation issue, not a gphoto2 issue. However, since you are using Python, I would like to draw your attention to the python bindings of gphoto where you can more natively interact with gphoto. https://github.com/jim-easterbrook/python-gphoto2/blob/master/examples/list-files.py contains an example how you can extract files straight from within python without running system commands. This is straightforward to modify to return only the number of file in your camera. Calling system commands from within python IMHO should be prevented if possible - it makes it cumbersome and very difficult to maintain. Maybe this helps ? Michael. On 14 July 2020 at 10:48 Antonio Cuni <[email protected]> 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] > 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] 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] https://lists.sourceforge.net/lists/listinfo/gphoto-user _______________________________________________ Gphoto-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gphoto-user _______________________________________________ Gphoto-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gphoto-user