Python Forum
Trying something that may not be possible?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying something that may not be possible?
#1
OK, buran helped my in another thread and I am immensely grateful.

Now I want to get the file names (including their path) on my hard drive. I have researched and researched and came up with something that I thought would work.

Here is my feeble attempt at doing a windows command prompt for the directory of C: hoping to use DIR command.
subprocess.run(["C:\\windows\\system32\\cmd.exe", "/C", "dir ", "c:*.*", " /S /O:N /B /L", "dirtest001.txt"],shell=True)

So, when running my script it gets to this and the error comes up "File not found" nothing else. Not sure what is wrong but...

Oh, some explanation:
I am trying to get the complete path and filename of the files on my hard drive and save it to a file. Using windows command I issue the command "dir c:\*.* /S /O:N /B /L >dirtest001.txt" and this works. Takes a while but works. "Porting" it into the subprocess.run command, well, I said it above.

Any help would be greatly appreciated.
Reply


Messages In This Thread
Trying something that may not be possible? - by fredep57 - Mar-16-2023, 09:02 PM

Forum Jump:

User Panel Messages

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