Cunoo 210 Posted November 1, 2018 Share Posted November 1, 2018 Hi guys, I want create "new" protection for client check files, but I have one little problem.. 90% of code working good, problem is os.remove() does not delete files in folder.. Here is my modified code: def BGMcheckFile(): BGM = os.listdir("BGM") Index = ["a_rhapsody_of_war.mp3", "back_to_back.mp3", "catacomb_of_devil.mp3", "death_of_landmark.mp3", "desert.mp3", "enter_the_east.mp3", "follow_war_god.mp3", "characterselect.mp3", "last-war2.mp3", "login_window.mp3", "lost_my_name.mp3", "m2bg.mp3", "monkey_temple.mp3", "mountain_of_death.mp3", "Only_my_battle.mp3", "open_the_gate.mp3", "save_me.mp3", "wedding.mp3", "wonderland.mp3", "xmas.mp3", "lastplay.inf"] if BGM != Index: for Data in BGM: if not Data in Index: try: os.remove(Data) except: app.Abort() if Index != BGM: for Data in Index: if not Data in BGM: app.Abort() else: pass BGMcheckFile() Someone know, where is problem? I tried use "os.chmod" for permission but same problem. Thanks for useful help Link to comment Share on other sites More sharing options...
ManiacRobert 427 Posted November 1, 2018 Share Posted November 1, 2018 os was disabled on windows 10. Link to comment Share on other sites More sharing options...
Premium tierrilopes 452 Posted November 1, 2018 Premium Share Posted November 1, 2018 You can do that easilly on the binary. Link to comment Share on other sites More sharing options...
Kori 170 Posted November 1, 2018 Share Posted November 1, 2018 Other way for windows import os os.system('del /F fileName.txt') Link to comment Share on other sites More sharing options...
Cunoo 210 Posted November 2, 2018 Author Share Posted November 2, 2018 16 hours ago, ManiacRobert said: os was disabled on windows 10. I use win 7. This is not my problem, but thank you. 15 hours ago, tierrilopes said: You can do that easilly on the binary. How? Please tell me if you have idea. 15 hours ago, Kori said: Other way for windows import os os.system('del /F fileName.txt') Thank you, but I need delete unexpected files in folders without my "index" if you know what I mean. Link to comment Share on other sites More sharing options...
Premium tierrilopes 452 Posted November 2, 2018 Premium Share Posted November 2, 2018 https://msdn.microsoft.com/en-us/library/b80153d8.aspx https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-findfirstfilea https://docs.microsoft.com/pt-pt/cpp/c-runtime-library/reference/remove-wremove?view=vs-2017 https://docs.microsoft.com/pt-pt/cpp/c-runtime-library/reference/stricmp-wcsicmp-mbsicmp-stricmp-l-wcsicmp-l-mbsicmp-l?view=vs-2017 1 Link to comment Share on other sites More sharing options...
Kori 170 Posted November 2, 2018 Share Posted November 2, 2018 3 hours ago, Cunoo said: I use win 7. This is not my problem, but thank you. How? Please tell me if you have idea. Thank you, but I need delete unexpected files in folders without my "index" if you know what I mean. import os files = [i for i in os.listdir() if i not in ('new_models', 'creat_model.py', 'my_mos.tit')] subprocess.call(['rm','-r'] + files) Or import glob files = [i for i in glob.glob("*") if i not in ('new_models', 'creat_model.py', 'my_mos.tit')] subprocess.call(['rm','-r'] + files) Link to comment Share on other sites More sharing options...
Denis 1474 Posted November 2, 2018 Share Posted November 2, 2018 Well, instead of removing them u can access them and just remove the content Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now