| name | file-locate-verify |
| description | Systematic workflow to resolve FileNotFoundError by locating and verifying file paths |
File Locate and Verify Workflow
When encountering FileNotFoundError or uncertain file paths, follow this systematic pattern to safely locate and verify files before executing operations.
When to Use
- You receive a FileNotFoundError or similar path-related error
- You need to work with files whose exact location is unknown
- You want to verify file existence before executing operations that depend on those files
Step-by-Step Procedure
Step 1: Check Current Directory Contents
First, use list_dir to inspect what files exist in your current working directory:
list_dir(path=".")
This reveals files in the immediate context and helps determine if you need to search elsewhere.
Step 2: Search for the File Using Find
If the file is not in the current directory, use the find command to locate it by name:
find . -iname "filename.pdf" 2>/dev/null
find / -name "filename.pdf" 2>/dev/null
Tips:
- Use
-iname for case-insensitive matching
- Redirect stderr with
2>/dev/null to suppress permission errors
- Narrow the search scope when possible for better performance
Step 3: Verify the Discovered Path