# ✅ PowerShell Script Fixed!

## Problem
The original `Fix-JellyfinPaths.ps1` had PowerShell syntax errors:
1. **Line 179**: XPath expression with variable interpolation caused parsing issues
2. **Line 213**: String terminator problem with nested quotes

## Solution
Created a new, corrected script: **`FixJellyfinPaths.ps1`** (no hyphen)

## What Was Fixed

### 1. XPath Query Issue
**Before (broken):**
```powershell
$element = $xml.SelectSingleNode("//*[text()='$($path.CurrentValue)']")
```

**After (fixed):**
```powershell
$element = $null
$xml.SelectNodes("//*") | ForEach-Object {
    if ($_.InnerText -eq $path.CurrentValue) {
        $element = $_
    }
}
```

This avoids XPath quote escaping issues by using direct comparison instead.

### 2. String Interpolation Issue
**Before (broken):**
```powershell
Write-Host "3. If issues persist, review backups in: $ConfigPath" -ForegroundColor White
```

**After (fixed):**
```powershell
$configInfo = "3. If issues persist, review backups in: $ConfigPath"
Write-Host $configInfo -ForegroundColor White
```

Separated the string building from the Write-Host call to avoid parsing ambiguity.

## How to Use

### Check for issues (dry run):
```powershell
.\FixJellyfinPaths.ps1 -DryRun
```

### Apply fixes:
```powershell
.\FixJellyfinPaths.ps1
```

### Apply without confirmation:
```powershell
.\FixJellyfinPaths.ps1 -Force
```

### Custom paths:
```powershell
.\FixJellyfinPaths.ps1 -ConfigPath "D:\Jellyfin\config" -DataPath "D:\Jellyfin\data"
```

## What It Does

1. **Scans** these config files:
   - `system.xml`
   - `encoding.xml`
   - `database.xml`

2. **Finds** any paths starting with:
   - `/var/`
   - `/usr/`
   - `/etc/`

3. **Fixes** them by:
   - Clearing `MetadataPath` and `TranscodingTempPath` (uses defaults)
   - Converting other Linux paths to Windows equivalents

4. **Creates backups** before making any changes

## Testing

Script tested and verified to parse correctly:
```
✓ No PowerShell syntax errors
✓ Handles non-existent paths gracefully
✓ Dry-run mode works correctly
```

## Files Updated
- ✅ `FixJellyfinPaths.ps1` - New corrected script
- ✅ `LINUX_PATH_ISSUE_SUMMARY.md` - Updated to reference new script name
- ✅ `FIX_SYSTEM_XML_PATHS.md` - Updated to reference new script name
- ❌ `Fix-JellyfinPaths.ps1` - Old broken script (can be deleted)

## Next Steps

1. Run the script with `-DryRun` to see what would be changed
2. If it looks correct, run without `-DryRun` to apply fixes
3. Restart Jellyfin
4. Check logs to verify paths are now correct
