Can the RecoverCompressedFile Tool restore several compressed images from a directory?

201 views
Skip to first unread message

orthent...@gmail.com

unread,
Jul 25, 2016, 3:01:31 PM7/25/16
to Orthanc Users
I need to restore serveral thousand compressed files to their original *.dcm format that reside in serveral different directories. I have tried using the RecoverCompressedFile Maintenance Tool which only completes the process if I specify each file by name one at a time. So I used the following script below to run the RecoverCompressedFile on each compressed file while descending through directories.

#!/bin/bash
# UnCompressedDir.sh

shopt -s globstar
for file in /home/Programs/orthanc/OrthancStorage/* OrthancStorage/**/*
do
/home/Programs/orthanc/Resources/Samples/Tools/RecoverCompressedFile "$file" /home/UncompressedDICOM/"$file" ;

done

This returns the Errors below. Is there a way to decompress multiple files in a directory sucessfully to their orignal DICOM state? Also I am migrating to a new PACS DICOM so I can't use the Replicate option. I tried the Direct Acces Method as well however that process is ingorning several of the images in OrthancStorage.

Reading the file into memory...
terminate called after throwing an instance of 'std::length_error'
what(): basic_string::resize
./UncompressDir.sh: line 4: 23962 Aborted (core dumped) /home/Programs/orthanc/Resources/Samples/Tools/RecoverCompressedFile "$file" /home/Programs/orthanc/OrthancStorage/"$file"
Reading the file into memory...
Decompressing the content of the file...
Error: Zlib: Corrupted compressed buffer
Reading the file into memory...
Decompressing the content of the file...
Error: Zlib: Corrupted compressed buffer
Reading the file into memory...
Decompressing the content of the file...
Error: Zlib: Corrupted or incomplete compressed buffer
Reading the file into memory...
Decompressing the content of the file...
Writing the uncompressed data...
Error: Cannot write to file

orthent...@gmail.com

unread,
Aug 8, 2016, 2:41:40 PM8/8/16
to Orthanc Users, orthent...@gmail.com


Ok no longer getting the buffering Errors however the script is not writing to the new location after decompression. I have given full write permissions to the directory. Any ideas? see script below.


#!/bin/bash

# Intialize Array, Find file names then put them into the Array

names=( $(find /home/Programs/testdev/OrthStorage -type f ) )

# Initialize counter

counter=0

# Print the count and filenames from the Array, Run the (RecoverCompressedFile) program, Pause for 1/20 of second, Loop it over

for dicom in "${names[@]}";

do let counter++; echo "Executing $dicom on file number $counter"; /home/Programs/orthanc/Resources/Samples/Tools/RecoverCompressedFile "$dicom" /home/Programs/testdev/NewStorage/"$dicom" ; sleep .2;

done

Sébastien Jodogne

unread,
Aug 16, 2016, 4:57:55 AM8/16/16
to Orthanc Users, orthent...@gmail.com
Hello,

IMHO, this looks like a problem with bash, not with Orthanc.

Please explain your question on StackOverflow, which is a better way of discussing bash-related issues:

Regards,
Sébastien-

orthent...@gmail.com

unread,
Sep 7, 2016, 2:50:55 PM9/7/16
to Orthanc Users, orthent...@gmail.com
On Monday, July 25, 2016 at 2:01:31 PM UTC-5, orthent...@gmail.com wrote:


Since my last post I finally determined what was happening with the buffering issue but didn't post the resolution. Of course as you mentioned it was bash related below is a script that automates the process. I'm sure it can be improved but it works. Thanks.

###############################################################################

#!/bin/bash

shopt -s globstar

# Intialize Array, Find file names from specific Dir then put them into the Array

names=( $(find /orthdata/volume1/OrthancVol1 -type f) )

# Initialize counter

counter=0

# Print the count and filename, Run the recovery (CPlus) program, Pause for 1/20 of second, Loop it over

for dicom in "${names[@]}"

do

# Remove paths from the Array

dicomimgs="${dicom##*/}"

# Use base filenames for new Array

dicomimgsnull="${dicomimgs%}"

# Display New filename

echo "New file name is ${dicomimgsnull}"

let counter++

echo "Executing $dicom on file number $counter"

/home/Programs/orthanc/Resources/Samples/Tools/RecoverCompressedFile "$dicom" /home/UncompressedDICOM/$dicomimgsnull ; sleep .2;


done

###############################################################################

Sébastien Jodogne

unread,
Sep 8, 2016, 3:12:59 AM9/8/16
to Orthanc Users, orthent...@gmail.com

Since my last post I finally determined what was happening with the buffering issue but didn't post the resolution.  Of course as you mentioned it was bash related below is a script that automates the process.  I'm sure it can be improved but it works. Thanks.


Thanks for sharing!

Sébastien-

Reply all
Reply to author
Forward
0 new messages