No need to over complicate things by developing a script to do what you want and to end your misery. You can do this using SQL, presuming you have access to the database.
If you are using MySQL 8+, you can use PREG_REPLACE in a query, as suggested in this SO article: How to remove all tag from column using a SQL query
UPDATE wp_posts
SET post_content = REGEXP_REPLACE(post_content, '<img.*?/>', '')
WHERE post_content LIKE '%<img%';
Note – it is strongly recommended to make a back up of your website or, at least, the database before doing any SQL operations.
Related Posts:
- How can I login to a website with Python?
- Upload file to SFTP using PowerShell
- Best way to automate the page/post publication process?
- Automating Page Creation
- Is there any free (or cheap) software that can be used for testing WordPress functionality?
- Is it possible to populate my wordpress site with many random posts for testing purposes?
- Automating Excerpt
- Are plugins like WP Robot considered as spammy by the community?
- Automatic publishing after some fixed intervals?
- WordPress Body Content How to add current page title automatically in different places?
- numpy array: IndexError: too many indices for array
- How do I specify new lines on Python, when writing on files?
- How to iterate over rows in a DataFrame in Pandas
- bash: pip: command not found
- TypeError: ‘NoneType’ object is not iterable in Python
- How do I check what version of Python is running my script?
- How to convert list to string [duplicate]
- How to uninstall a package installed with pip install –user
- Converting integer to string in Python
- Python for-in loop preceded by a variable
- What does if __name__ == “__main__”: do?
- How to measure elapsed time in Python?
- not all arguments converted during string formatting.. NO % variables
- TypeError: ‘builtin_function_or_method’ object is not subscriptable
- numpy max vs amax vs maximum
- What does “while True” mean in Python?
- TypeError: ‘str’ object is not callable (Python)
- ModuleNotFoundError: No module named ‘sklearn’
- Does Python have an ordered set?
- python re.split() to split by spaces, commas, and periods, but not in cases like 1,000 or 1.50
- Asking the user for input until they give a valid response
- Print a list in reverse order with range()?
- Configuring so that pip install can work from github
- Proper way to declare custom exceptions in modern Python?
- TypeError: ‘float’ object not iterable
- write() versus writelines() and concatenated strings
- Why is it string.join(list) instead of list.join(string)?
- How to read a .xlsx file using the pandas Library in iPython?
- What is a Python egg?
- Numpy/Python Array Value error
- Changing the “tick frequency” on x or y axis in matplotlib?
- TypeError: unsupported operand type(s) for -: ‘str’ and ‘str’
- Remove all special characters, punctuation and spaces from string
- AttributeError: ” object has no attribute ”
- Plot pie chart and table of pandas dataframe
- ModuleNotFoundError: No module named ‘matplotlib’
- Install mysql-python (Windows)
- “inconsistent use of tabs and spaces in indentation”
- Grep and Python
- What does the percentage sign mean in Python
- Pandas ‘count(distinct)’ equivalent
- How can I flush the output of the print function?
- Python calling method in class
- No module named pkg_resources
- TypeError: list indices must be integers or slices, not str
- python object() takes no parameters error
- Inorder Binary Tree Traversal (using Python)
- How do I find the distance between two points?
- How do I calculate percentiles with python/numpy?
- Why is IoC / DI not common in Python?
- How do I remove a substring from the end of a string?
- Selecting with complex criteria from pandas.DataFrame
- Is ‘# -*- coding: utf-8 -*-‘ also a comment in Python?
- How can I download Anaconda for python 3.6
- django:django.core.exceptions.AppRegistryNotReady: Apps aren’t loaded yet
- Replace and overwrite instead of appending
- How to make a histogram from a list of data
- Using __add__ operator with multiple arguments in Python
- How to constantly run Python script in the background on Windows?
- Django – “no module named django.core.management”
- Type error Unhashable type:set
- How can you print a variable name in python? [duplicate]
- Windows path in Python
- Python: ValueError: Mixing iteration and read methods would lose data
- python: restarting a loop
- “for loop” with two variables?
- Display number with leading zeros
- Running Python in PowerShell?
- Why do many examples use `fig, ax = plt.subplots()` in Matplotlib/pyplot/python
- ImportError: No module named model_selection
- Numpy – add row to array
- How to change pip installation path
- What is the difference between a string and a byte string?
- Rolling or sliding window iterator?
- What is a namespace object?
- How to serve static files in Flask
- How to create Gephi network graphs from Python?
- strncmp in python
- How can I count time in Python 3?
- Is it possible to forward-declare a function in Python?
- Python OpenCV2 (cv2) wrapper to get image size?
- Modular multiplicative inverse function in Python
- KeyError: ‘plotly_domain’
- The value of _stdout is incorrect
- Can I do in-page changes binding events/triggers to actions in WordPress?
- How to auto-generate names for guest users who leave comments?
- Assignt automatically two categories by author
- WordPress NOT notifying of new update in dashboard
- Importing large number of RSS feeds
- Automate the installation of postfix on Ubuntu