Dear Andreas,
I had the same problem frequently and wrote a little python-script for
compressing our images on our server. It might help you and you can
easily modify the extension for which the script should search for...
Best Regards,
Georg
------ code starts below ----
#!/usr/bin/python
#
# script to compress all xray images (as specified in variables) downstream
# of a specfied directory using as many cores as available on the system
#
# requirement: python >= 2.4, bzip2
# tested with systems: MacOS X (10.5.7), ubuntu 8.04.2 (LTS)
#
# USAGE AT YOUR OWN RISK
# georg.zoc...@gmx.de
#
#
# version 0.1
#
import os, sys, subprocess
##### variables
# You can modify the data types here....
imagetypes = [".ccd", ".img", ".cbf", "mar2300"]
# If you only want to get a file list without compressing anything
switch to 'on'
debug = 'off'
#############################################################################################
#############################################################################################
##### do not modify anything below this line unless you know what you
are doing
images = []
usage = """
\t usage: \t image_compressor <directory> \n
\t\t\t All image files downstream the specified <directory> will
'bzip2'-ed on several cores
\t\t\t USAGE AT YOUR OWN RISK....\n"""
### check input
try :
sys.argv[1]
except:
print
print "\t Please specify a directory to dive into..."
print usage
sys.exit(0)
check = os.path.exists(sys.argv[1])
if check == True:
input = os.path.abspath(sys.argv[1])
if check == False:
print
print "\t Specified directory not found..."
print usage
sys.exit(0)
### functions
def __get_images():
""" Function to get all xray image files downstream of a specified
directory
return value is a list...
"""
print "\n\t generating file list"
for dir, dirs, files in os.walk(sys.argv[1]):
for f in files:
if os.path.splitext(f)[1] in imagetypes :
images.append((os.path.join(dir, f)))
print "\n\t\t\t...done"
return images
def __get_ncpu():
""" Function to get the number of CPU-Cores on POSIX systems
"""
try:
ncpu = int(os.sysconf('SC_NPROCESSORS_ONLN'))
if ncpu > 0:
return ncpu
except (AttributeError,ValueError):
#pass
print "\n\t System not POSIX compatible. Sys.exit...\n"
sys.exit(0)
def run_bzip(ncpu, list):
dic = {}
j=0
list.sort()
while j <= len(list):
for i in range(ncpu):
if j >> len(list):
break
if j <= len(list):
print "\t compressing image:", os.path.basename(list[j-1])
try:
if debug == "off":
dic[i] = subprocess.Popen([r"bzip2","-z9",
list[j]])
#for testing....
if debug == "on":
dic[i] = subprocess.Popen([r"ls","-l", list[j]])
except:
print
j+=1
dic[i].wait()
def main():
run_bzip(__get_ncpu(), __get_images())
### end functions
if __name__ =='__main__':
main()
---- code end above ----
Am 09.02.11 15:49, schrieb Andreas Förster:
Dear all,
I'm trying to create some space on our server and want to compress all
x-ray data files. I'm wondering what extensions I should search for.
mccd and img come to mind easily. What other extensions are commonly
used?
Thanks.
Andreas
--
Universität Tübingen
Interfakultäres Institut für Biochemie
Dr. Georg Zocher
Hoppe-Seyler-Str. 4
72076 Tuebingen
Germany
Fon: +49(0)-7071-2973374
Mail: georg.zoc...@uni-tuebingen.de
http://www.ifib.uni-tuebingen.de