Not sure if I am the only one, but the current naming convention makes sorting a bit difficult.
I create my sequence in the way where I set 4 frames for each channel, have it cycle through all channels, and repeat. When I load everything to for exmaple Blink in PI, it’s sorted by the # of cycles (_001, _002, etc.). In this case I really want it to be sorted by time, or maybe other keywords in other use cases. So I wonder if it’s possible to enable the user to name the files, and if not is it possible to move the cycle # to the end.
As a workaround, I found an app that allows batch renaming of files, and I use that to remove the series numbers from each file name. Then the files sort as expected. It is an extra step, though.
I would also like to have file names where at least the number comes after the date.
I’ve created a python script which renames FIT files.
So for example this name:
NGC1275_LIGHT__BayerMatrix__180s_BIN1_-5C_001_20201121_205129_742_W.FIT
becomes:
NGC1275_LIGHT__BayerMatrix__180s_BIN1_-5C_20201121_205129_742_001_W.FIT
Yizhou, I can send you the script if you need such renaming.
This script is for Python 3. Start it (py fixname.py) from the directory where the FIT files are located. It will rename only files were the sequence number is before the date and skip other files. I usually run it from the root of the sequences directory on an external SSD, where the calibrated frames are stored.
As always in such cases: the script comes with no warranty of any kind, use it at your own risk. I do
Vitali
from os import listdir, rename
from os.path import isdir, isfile, join
from pathlib import Path
import re
def RenameFiles(Dir):
# Read the list of files
AllFiles = [f for f in listdir(Dir) if isfile(join(Dir, f))]
ImageFiles = []
for name in AllFiles:
if '.xisf' in name or '.FIT' in name:
ImageFiles.append(name)
if len(ImageFiles) <= 0:
return 0
cRenamed = 0
# Check all names
for ImageFile in ImageFiles:
# Check if the name contains "_001_20201106_035740_058_E"
r = '_[0-9]{3}_[0-9]{8}_[0-9]{6}_[0-9]{3}_[E|W]'
m = re.search(r, ImageFile)
if m == None:
#print("Skipped " + ImageFile)
continue
# Split the string to 4 parts: prefix, seqnum, date, suffix
sPrefix = ImageFile[0:m.start()]
sSeqNum = ImageFile[m.start():m.start()+4]
sDate = ImageFile[m.start()+4:m.end()-2]
sSuffix = ImageFile[m.end()-2:]
# Re-assemble, moving the seqnum after the date
sNewName = sPrefix + sDate + sSeqNum + sSuffix
sOldPath = join(Dir, ImageFile)
sNewPath = join(Dir, sNewName)
if isfile(sNewPath):
#print("Skipped (target exists): " + ImageFile)
continue
#print(ImageFile)
rename(sOldPath, sNewPath)
cRenamed = cRenamed + 1
return cRenamed
def ProcessDir(Dir):
print('*** ' + Dir)
cRenamed = RenameFiles(Dir)
print(str(cRenamed) + ' files')
AllDirs = [f for f in listdir(Dir) if isdir(join(Dir, f))]
for Subdir in AllDirs:
ProcessDir(join(Dir, Subdir))
return
ProcessDir('.')
You both are much more sophisticated than I am. One of these days I may teach myself Python. For now, I use a Mac app called Name Mangler 3 and recommend it highly. I’ll include the link below for posterity.
Hello.
I have the same request.
I have to change manually the file names every day.
I’ve been looking for how to do it at Voyager, and after reading you I see it’s not possible at the moment.
If you make several sessions of the same objet, when importing files to Pixinsight they are ordered by 001, 002 etc. And I have several 001, 002 etc one for each night. And not by date/time.
I’m not an expert. Processing images, for me, is something mysterious and difficult! Like making voodoo!
I only know Pixinsight for processing images. I have the books from Keller and Rogelio.
And Adam Block video tutorials. I think it’s becoming an standard in image processing.
Anyway it’s my opinion and experience from friends and associations. I don’t want to create controversy about it).
In all of tutorials, the process begins with the visual inspection of images, and in Pixinsight you do it with “Blink”.
It shows you all the images, but you can’t not decide the order!.
So they are ordered alphabetically. That’s why the 001, 002 etc avoid a correct order by time/date.
If you see my picture attached, you’ll see that I have six 001 images all from different days and time, so some times images are flipped etc.
And if you have a focus error, for example, it uses to be in continuous images… And with the 001, 002 etc, they are all separated.
Perhaps it’s no so important, but it should be fine if the name, or at least the 001, 002 were in a different position, and the name could be order by date automatically. Or if each user could determine the name structure at his own.
Leonardo, thank you very much for implementing this feature. It is very useful for those who take images of one target during multiple nights.
Sorting by the acquisition time is the natural order, because this is how the observing conditions evolve: clouds, seeing, etc.
PixInsight tools usually sort the files by name. For example the SubframeSelector tool allow me to see the graphics representation of eccentricity, FWHM, median, etc. And when the files are sorted by the acquisition date, I can easily see such things as worsened seeing or a cloud and reject such frames.
For me, and other people who requested this feature, it is more convenient to have the sorting by name be equal to the sorting by date.
Sorry Vitali, I use CCDStack for stacking that order in anyway I want without looking at name of file and I use PI after just some tasks and for short focal lenght. So I dont know about PI problem on order file only using filename.
Looks great!
It looks like there is an option to just have a sequential number after the file name which is what I need to assist finding particular frames in a list.
This will be a big time saver. Thank you Leo for making it a priority.
This is awesome Leo! Thanks for including it. It’ll really help the review of individual files in the blink tool in PI for me as well. No worries on the general file name changes on my end either. I’m reading now directly from the FITs header.