Last active
January 28, 2024 09:20
-
-
Save adithyasource/ef9c939a1283e738c363a1a72914ea49 to your computer and use it in GitHub Desktop.
are.na read all webloc files from .zip channel export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
channel = "NAME OF FOLDER" | |
dirPath = "LOCATION OF FOLDER" | |
count = 0 | |
finalString = "" | |
for path in os.listdir(dirPath): | |
file = os.path.join(dirPath, path) | |
if os.path.isfile(file) and file.split(".")[-1] == "webloc": | |
count += 1 | |
f = open(file, "r") | |
fixedContents = ( | |
str(f.read()) | |
.replace("URL =", "") | |
.replace(";", "") | |
.replace("{", "") | |
.replace("}", "") | |
.replace('"', "") | |
.strip() | |
) | |
finalString += fixedContents + "\n" | |
f = open(f"{channel}.txt", "a") | |
f.write(finalString) | |
f.close() | |
print(f"written to {channel}.txt" + "\n" + "file count:", count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment