Skip to content

Instantly share code, notes, and snippets.

@omsai
Created December 1, 2011 16:40
Show Gist options
  • Save omsai/1418062 to your computer and use it in GitHub Desktop.
Save omsai/1418062 to your computer and use it in GitHub Desktop.
Workaround for Andor iQ bug# 6028. Run this in the iQ Python IDE
import imagedisk
import logging
REPLACE_DOT_WITH_CHAR = '_' # Replace dot with underscore
LOG_FILENAME = 'iQ_filename_fixer.log'
id = imagedisk.iQImageDisk()
##logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)
logging.basicConfig(level=logging.DEBUG)
changed = 0
unchanged = 0
logging.info('Renaming files to replace `.`with `' + \
REPLACE_DOT_WITH_CHAR + '`...')
for im in id:
name = im.getTitle()
new_name = name.replace('.', REPLACE_DOT_WITH_CHAR)
if name == new_name:
unchanged = unchanged + 1
else:
logging.info(repr(name) + ' -> ' + repr(new_name))
im.setTitle(new_name)
changed = changed + 1
if changed == 0:
logging.info('Nothing to change. No dataset names have `.` in them')
else:
logging.info('Fixed ' + str(changed) + ' dataset names')
logging.info(str(unchanged) + ' dataset names unchanged')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment