Skip to content

Instantly share code, notes, and snippets.

@blu3mo
Created March 4, 2023 02:35
Show Gist options
  • Save blu3mo/91eb883d8277170de35145cfeca853af to your computer and use it in GitHub Desktop.
Save blu3mo/91eb883d8277170de35145cfeca853af to your computer and use it in GitHub Desktop.
Python script to remove scrapbox pages that has specific string.
""" 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