0

I am using this python script:

import dbg
import app
import os
def RunCheckUp():
    Whitelist = [
        'Folder1',
        'Folder2',
        ]

    path = os.getcwd()
    k = os.listdir(path)
    if k != Whitelist:
        for item in k:
            if not item in Whitelist:
                dbg.LogBox("The next file will be deleted: " + str(item))
                try:
                    os.remove(item)
                except:
                    dbg.LogBox("Delete this file " + str(item) + " pentru a putea juca.")
                    dbg.LogBox("The program will be closed.")
                    app.Abort()
            else:
                pass
    if Whitelist != k:
        for missing in Whitelist:
            if not missing in k:
                dbg.LogBox("The program can't start! This file is missing: " + str(missing))
                app.Abort()
            else:
                pass
RunCheckUp()

My question is how to add a file that is in the Folder2, I want do add "file1" and "file2" because I want to protect file1 and file2 from deleting not just the folder Something like this Folder2/file1

5
  • Possible duplicate of stackoverflow.com/questions/18388368/… Commented Jul 25, 2015 at 18:13
  • Wouldn't all the files in a folder be "protected" if the folder itself is? Commented Jul 25, 2015 at 19:09
  • they are not, this just protect the name if the file is missing i get this The program can't start! This file is missing but if i ad a new file in the Folder1 directori i get this The next file will be deleted i want to do the same thing but with the files in folder2 directory Commented Jul 25, 2015 at 19:13
  • this script detect missing files or files that don't belong in some directory Commented Jul 25, 2015 at 19:16
  • I can show you how this program work does sombody have an idea how should I do this Commented Jul 26, 2015 at 11:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.