Skip to content

Instantly share code, notes, and snippets.

@adithyasource
Last active January 28, 2024 09:20
Show Gist options
  • Save adithyasource/ef9c939a1283e738c363a1a72914ea49 to your computer and use it in GitHub Desktop.
Save adithyasource/ef9c939a1283e738c363a1a72914ea49 to your computer and use it in GitHub Desktop.
are.na read all webloc files from .zip channel export
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