This Python script reads a file, modifies its content, and writes the modified version to a new file. It also includes error handling to manage cases where the file doesn't exist or can't be read.
- Reads a user-specified text file.
- Converts the content to uppercase (modification step).
- Writes the modified content to a new file prefixed with
modified_
. - Handles errors gracefully, such as file not found or permission issues.
- Run the script:
python file_modifier.py
- Enter the filename when prompted.
- If the file exists, a modified version will be created with a
modified_
prefix. - If the file is missing or unreadable, the script will display an error message.
Hello, world!
Python is great.
Creates modified_example.txt
:
HELLO, WORLD!
PYTHON IS GREAT.
- If the file doesn't exist:
Error: File not found. Please check the filename and try again.
- If the file is unreadable:
Error: Unable to read the file. Check permissions or file format.
- Python 3.x
This project is open-source under the MIT License.