Rebuild new index file

Hi Team.

Excuse me for writing, but I’ve tried everything and haven’t been able to find a solution. Programming isn’t my thing, but I’m doing my best.

I have Orthanc installed on a computer where both hard drives have been damaged. I had a backup in the cloud, using a personal OneDrive account, created using the Windows 10 backup system.

It turns out the backup was created, but when I unzip the index file, it fails, and I haven’t found a way to recover it. I’ve tried ChatGPT, Gemini, and several AIs, and they tell me I should add the ReconstructIndex command to the orthanc.json file, but nothing happens. A day has passed, and nothing has happened, and the new index file isn’t growing. I was going to try the tool in Python, but according to the AI, the files should be unzipped, and apparently the StorageCompression option was set to true.

I even tried the indexer option, using the folder with all the files, but according to the AI, it fails because the files are compressed.

The truth is, I’m desperate. It’s 128GB of data, with hundreds of case studies from the University of Zulia in Venezuela.

Any help or insight you can give me, I will be eternally grateful.

Thank you very much
Daniel Ladeda

Hi @ladeda

The "ReconstructIndex" configuration does not exist but it seems it is a common AI hallucination.

If the previous storage was compressed, you can use the OrthancRecoverCompressedFile.exe <input> [output] tool to uncompress a file (it is saved in C:\Program Files\Orthanc Server\Tools)

Then, you can use an AI tool to write a program to generate a script to process the backup folder recursively: Here is a prompt that should work:

can you write a powershell script that parses a folder recursively, calls an exe whose usage is OrthancRecoverCompressedFile.exe <input> [output] and that would generate the output in a new folder

Then, you can use the ImportDicomFiles.py script to re-import in a new Orthanc (make sure the IndexDirectory and StorageDirectory is yet another new empty folder).

Hope this helps,

Alain.

Hi AlainMazy. Thanks for responding. After much searching and searching, I’m finally able to unzip the files. I managed to create a .bat file to unzip everything into a folder and then re-import it.

I’m posting the .bat file here for your use.

@echo off
setlocal enabledelayedexpansion

:: === CONFIGURATION ===
set "INPUT_DIR=C:\Orthanc"
set "OUTPUT_DIR=C:\Recovery"
set "TOOL=C:\Program Files\Orthanc Server\Tools\OrthancRecoverCompressedFile.exe"
set "LOG=C:\Program Files\Orthanc Server\Tools\recover_all.log"
set "MIN_SIZE=2048"    :: minimum size in bytes to try (adjust if you want)

echo ================================================== > "%LOG%"
echo Start: %date% %time% >> "%LOG%"
echo Origin: %INPUT_DIR% >> "%LOG%"
echo Exit: %OUTPUT_DIR% >> "%LOG%"
echo MinSize: %MIN_SIZE% bytes >> "%LOG%"
echo ================================================== >> "%LOG%"

if not exist "%OUTPUT_DIR%" mkdir "%OUTPUT_DIR%"

for /R "%INPUT_DIR%" %%F in (*) do (
    set "name=%%~nF"
    set "ext=%%~xF"
    set "size=%%~zF"

    rem Avoid small files and databases
    if NOT "!ext!"==".db" if NOT "!ext!"==".wal" if NOT "!ext!"==".shm" if !size! GTR %MIN_SIZE% (
        set "rel=%%~pF%%~nF"
        set "rel=!rel:\=_!"
        set "out=%OUTPUT_DIR%\!rel!.dcm"

        if not exist "!out!" (
            echo Procesando: "%%F" size=!size! >> "%LOG%"
            "%TOOL%" "%%F" "!out!" >> "%LOG%" 2>&1

            if exist "!out!" (
                echo OK: "!out!" >> "%LOG%"
            ) else (
                echo FAIL: "%%F" >> "%LOG%"
            )
        ) else (
            echo SKIP_EXISTE: "!out!" >> "%LOG%"
        )
    )
)

echo Fin: %date% %time% >> "%LOG%"
echo ================================================== >> "%LOG%"
echo Process completed. Review %LOG% and folder %OUTPUT_DIR%
pause

Thank you very much!

1 Like