Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generate a list
#1
How to generate a list of all the ‘.exe’ files available in ‘C:\Windows\system32’ directory and store them in a log file created in the C drive with the name of ‘entries_Win10.log’.

Attached Files

Thumbnail(s)
   
Reply
#2
What have you tried?

This is a place for helping people to learn Python, not for people to solve your problems for you. If you're not going to write code, we have nothing to help with.
buran and ndc85430 like this post
Reply
#3
You should try yourself as this is a relative easy task,we do not like a task posted without any effort,then is more job description.
That's said here a start(saving to log file you should try yourself), these days pathlib is a more modern way to do it.
import pathlib

win_dir = r'C:\Windows\System32'
for file in pathlib.Path(win_dir).glob('*.exe'):
    if file.is_file():
        print(file)
nilamo likes this post
Reply
#4
sasitha96,

The code provided works, of course you can simply capture to a file or code the file capture in Python. Or you could use DOS

C:\Windows\System32>dir *.exe >> E:\\mafiles.txt

Or run the Python code and output to a file:

C:\python3.8.5>python check.py >> EXEFILES.TXT


Best,
Dave
sasitha96 likes this post
Reply
#5
(Sep-19-2021, 06:47 PM)nilamo Wrote: What have you tried?

This is a place for helping people to learn Python, not for people to solve your problems for you. If you're not going to write code, we have nothing to help with.

sorry for that Undecided
Reply
#6
(Sep-19-2021, 06:48 PM)snippsat Wrote: You should try yourself as this is a relative easy task,we do not like a task posted without any effort,then is more job description.
That's said here a start(saving to log file you should try yourself), these days pathlib is a more modern way to do it.
import pathlib

win_dir = r'C:\Windows\System32'
for file in pathlib.Path(win_dir).glob('*.exe'):
    if file.is_file():
        print(file)

thanks Heart
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to generate a log in a list style? wagnergt12 5 2,736 Apr-22-2020, 12:47 PM
Last Post: buran
  extract first and last 5 elements from given list and generate a new list. Raj_Kumar 1 2,367 Dec-07-2019, 05:03 PM
Last Post: ichabod801
  I created a function that generate a list but the list is empty in a new .py file mrhopeedu 2 2,286 Oct-12-2019, 08:02 PM
Last Post: mrhopeedu
  Generate list in class P13N 7 4,330 Dec-28-2018, 10:08 PM
Last Post: P13N
  Generate a list of numbers within a list of arbitrary numbers Takeshio 4 3,479 Nov-08-2018, 12:29 AM
Last Post: Takeshio
  How to generate the list I want? Krookroo 6 4,076 Sep-07-2017, 02:06 PM
Last Post: Krookroo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020