Kodi Community Forum

Full Version: Convert ISO CDFS to UDF with Powershell
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If like me you find yourself with a collection of ISO files formatted under the CDFS file system rather than the UDF file system, you can convert these in batch easily.

For this, I used the latest version of Daemon Tools Lite - Free license (www.daemon-tools.cc).

What my script does is locate all ISO files under a root path, and mount each ISO file using Daemon Tools. Once mounted, the file system can be read using .NET System.IO.DriveInfo properties, and any that are not CDFS can be skipped. If CDFS, a new ISO is created using MKISOFS and the -dvd-video switch, and if successful the old ISO is unmounted, deleted, and replaced by the new ISO. This has converted many hundreds of ISO files for me already so that they now play properly in XBMC.

Warning: Use this Powershell script at your own risk. Revise the appropriate configuration variables to fit your system. Test it thoroughly to make sure it does what you need and want.

$path_movies is the root path to your ISO collection
$path_mount is the full path to the Daemon Tools drive that gets mounted
$path_temp is the folder for building the new ISO (it can be on a separate hard drive, or not)

All path variables must end in a backslash.

$app_mkisofs is the path to your MKISOFS.EXE executable
$app_dtlite is the path to your DTLite.exe executable

Code:
$ErrorActionPreference='Stop'

$path_movies = "x:\users\public\videos\"
$path_mount = "h:\"
$path_temp = "x:\temp\"

$app_mkisofs = "d:\Program Files\misc\mkisofs\mkisofs.exe"
$app_dtlite = "c:\Program Files (x86)\DAEMON Tools Lite\DTLite.exe"

$iso_files = get-childitem $path_movies -recurse *.iso
foreach ($iso_file in $iso_files)
{
    $parms = "-unmount dt, 0"
    start-process $app_dtlite $parms -wait    
    sleep -s 1
    
    $parms = "-mount dt, 0, ""$($iso_file.fullname)"" "
    start-process $app_dtlite $parms -wait
    sleep -s 1
    
    $di = new-object system.io.driveinfo($path_mount)
    if (($di.isready -eq $true) -and ($di.driveformat -eq "CDFS") -and ($di.volumelabel -ne ""))
    {
        $iso_temp = "$($path_temp)$($iso_file.name)"      
        $parms = "-J -joliet-long -jcharset iso8859-1 -l -r -dvd-video -V ""$($di.volumelabel)"" -o ""$($iso_temp)"" ""$($path_mount)."" "
        start-process $app_mkisofs $parms -wait
        
        $fi = new-object system.io.fileinfo($iso_temp)
        if (($fi.exists -eq $true) -and ($fi.length -ge $iso_file.length))
        {
            $parms = "-unmount dt, 0"
            start-process $app_dtlite $parms -wait    
            sleep -s 1
                
            $iso_file.delete()
            $fi.moveto($($iso_file.fullname))
        }
    }    
}

$parms = "-unmount dt, 0"
start-process $app_dtlite $parms -wait    
sleep -s 1