This PowerShell script recursively scans a folder for XML files, converts each file into a structured JSON format, and saves the results to a specified output file. It also captures useful metadata such as file path, creation time, and last modification time.
- π Recursively parses XML files in a given directory
- π Converts XML content into nested JSON structures
- π Captures file metadata (path, creation time, modification time)
- πΎ Outputs a single compressed JSON file
- π οΈ Gracefully handles malformed XML files
.\parse_tasks.ps1 -inputFolder "C:\path\to\xml\files" -outputFile "C:\path\to\output.json"| Parameter | Description |
|---|---|
-inputFolder |
Path to the folder containing XML files |
-outputFile |
Path to the resulting JSON output file |
- Recursively scans the input folder for
.xmlfiles. - Parses each XML file into a dictionary-like structure.
- Extracts metadata: file path, creation time (UTC), and last modified time (UTC).
- Serializes the results into a compressed JSON format.
- Saves the final output to the specified file.
Each entry in the output JSON file includes:
{
"Path": "C:\\path\\to\\file.xml",
"Created": "2025-07-07T06:12:34.0000000Z",
"Modified": "2025-07-07T06:15:00.0000000Z",
"Task": {
"RootElement": {
"ChildElement": "Value",
"Attributes": "..."
}
}
}- Files that fail XML parsing are skipped with a warning.
- The script continues processing remaining files without interruption.
This project is licensed under the MIT License.