Created
March 4, 2023 02:35
-
-
Save blu3mo/91eb883d8277170de35145cfeca853af to your computer and use it in GitHub Desktop.
Python script to remove scrapbox pages that has specific string.
This file contains hidden or 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
""" remove all pages that contain the word "private.icon" """ | |
import json | |
# Load the JSON data | |
with open('blu3mo.json') as f: | |
data = json.load(f) | |
# Loop through each page in a copy of the data | |
for page in list(data['pages']): | |
# Check if any line in the page includes the word "private.icon" | |
if any('[private.icon]' in line for line in page['lines']): | |
print(f"Removing page {page['title']} because it contains '[private.icon]'") | |
# Remove the page from the original data list | |
data['pages'].remove(page) | |
# Write the updated JSON data to file | |
with open('blu3mo_cleaned.json', 'w') as f: | |
json.dump(data, f, indent=2, ensure_ascii=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment