Jan-05-2024, 04:44 PM
In version 2, the get_folder_contents get all files in folder, plus files that are in subdirectories of folder. For obvious reasons this will not work if you want to find out what files are in C:\Folder-Oana\extracted but are not in C:\Folder-Oana\extracted\translated. All files in html_files_folder2 will also be in html_files_folder1 because folder 2 is a subdirectory of folder 1.
I don't know why version 1 wouldn't work. It worked fine for me.
Stop using "\" and start using "/" for the separator in file paths. Windows accepts "/" and it eliminates the confusion of "\" maybe being the start of an escape sequence.
I don't know why version 1 wouldn't work. It worked fine for me.
import os a = set(f.lower() for f in os.listdir(".") if f.lower().endswith(".py")) b = set(f.lower() for f in os.listdir("./test") if f.lower().endswith(".py")) print("A or B", *(a | b), sep="\n") print("", "A and B", *(a & b), sep="\n") print("", "A but not B", *(a - b), sep="\n") print("", "B but not A", *(b - a), sep="\n")
Output:A or B
junk.py
console.py
junk2.py
junk3 copy.py
junk3.py
pythonhighlighter.py
interactiveconsole.py
sqlite_demo.py
monkeypatching.py
A and B
junk.py
junk2.py
junk3.py
A but not B
console.py
pythonhighlighter.py
interactiveconsole.py
sqlite_demo.py
monkeypatching.py
B but not A
junk3 copy.py
There may be a slight problem with Larz60+ code. Files with the extension ".HTML" will not be included in the list because "html" != "HTML".Stop using "\" and start using "/" for the separator in file paths. Windows accepts "/" and it eliminates the confusion of "\" maybe being the start of an escape sequence.