There was a problem with the identification of files in this directory with the win 10 OS after the last update (before that, the script worked on the wines 10), and on other versions of windows everything works. Code:

import dbg import app import os def RunCheckUp(): Whitelist = ['test.dll','C.exe','folder','blabla.exe','xd.exe','plugins'] path = os.getcwd() arr = [] t = os.walk(path) for k in next (t): arr.append("/" + path + "/" + str(k)) if k != Whitelist: ####Starting_Phase01##### for item in k: if not item in Whitelist: dbg.LogBox(" Удаление не нужного файла: " + str(item)) try: os.remove(item) except: dbg.LogBox(" Прога сейчас закроется! ") dbg.LogBox(" Удалите лишний файл: " + str(item)) app.Abort() else: pass RunCheckUp() 

Error on win 10: Error on win 10

ps Tried to change the path by adding / but there is no result arr.append ("/" + path + "/" + str (k))
p.s2 also tried the directory verification code like this:

  path = os.getcwd() k = os.listdir(path) 

In this case, the error is again only on win10, while on others the windows version all works. Win10 Error: enter image description here

  • Here it is accepted to write questions in Russian. It is not welcome to translate the question into Russian instead of the author, because the author may not agree with the translation of his text - and a conflict will arise. For questions in English, you can ask a question in the English version of the site. - nick_n_a
  • The built-in translator in the browser translated itself, I did not look at the press to publish, I agree with the translation. - test test

1 answer 1

I tried your code. it is fully working on even at the last 10. Single, I don’t understand these are used libraries ... are these your modules?

 import os def RunCheckUp(): Whitelist = ['test.dll','C.exe','folder','blabla.exe','xd.exe','plugins'] path = os.getcwd() arr = [] t = os.walk(path) for k in next (t): arr.append("/" + path + "/" + str(k)) if k != Whitelist: ####Starting_Phase01##### for item in k: if not item in Whitelist: print " Удаление не нужного файла: " + str(item) try: os.remove(item) except: print " Прога сейчас закроется! " print " Удалите лишний файл: " + str(item) else: pass RunCheckUp() 

if I understand you correctly, then with this code you can delete files and folders that are not included in the white list and only in the directory where the script itself is located

  • These libraries are used in the game client according to the standard (for working with .exe). But I don’t understand why on some win 10 these errors are given .. Not on all windows 10, but after some update (maybe the last one). Yes, you correctly understood, this is a script for checking files, if there is no file in Whitelist, but it is in the game folder, this file is deleted. - test test
  • "I tried your code. It is fully working on even the last 10." - maybe the problem with os.getcwd win10 does not read the path correctly .. should like this: D: \ Test *. * and it reads like this: D: \\ Test /*.* (as seen from the last screenshot) - test test
  • almost ... on the second and third python os.getcwd gives you a way through / slash, which allows not to screen it and specify additional addresses for, for example, some_path + '/ some_othe_folder' ... at least on my Windows and linuhe ... perhaps I am only supposing, but not claiming, this may depend on the regional project. try to use / this slash - Konstantin Kozlenko
  • I still could not figure it out, and I had a slash / in the code .. I implemented it through c ++ - test test
  • ok, let's do it together. please tell us what these dbg and app libraries are doing - Konstantin Kozlenko