|
Post by spohnz on May 22, 2017 8:41:26 GMT -6
I wrote this to find a couple of files I had thought were missing. import os def oswalk(): f=open('AllPortableApps.txt', 'a') for folderName, subFolders, fileNames in os.walk('C:\\'): for x in fileNames: if x[-3:].lower() == '.py': f.write((folderName + '\\' + str(x) + '\n')) f.close() oswalk( )
if you need to change the .py to a .exe or something. Mind that the string is striped to the last 3 characters (-3) so change that to -4 instead. 1st line imports the OS 2 writes a quick function 3 creats and opens a file to store the result in. the 'a' is append. We are appending (adding) each find to the file. 4 starting search in the root folder C: 5 taking each file name as it loops and seeing if the last 3 characters match '.py' 6 writes to f, which is the text file we stored as f on line 3 7 when finished, it closes the file. <-- always close your files. 8 run our function in this script. Hope someone finds this useful I did.
|
|