Changing the image filenames to incorporate a timestamp #1548
Replies: 3 comments
-
@KMBlundell Hi, I never programmed in bash before helping with Allsky, although I programmed in sh and ksh (which is very similar to bash). The reason dashes aren't being added to the date is most likely this line: DESTINATION_FILE="$(FN-$(date +'%Y-%m-%d_%H-%M-%S').$EXT)" The Re: A basic assumption in Allsky is that whatever displays images only displays the current image. This is true in the Live View of the WebUI and the Allsky Website, be it on the Pi or a remote server. This is why there's no way to upload a file with a non-static name.
to Would this work for your? When an image is first saved to disk by the capture programs, it has a name of
where This statement:
is in a block of code that implements the ability to to only upload every Nth image, for example, every 3rd image. Line 182 is executed if the CURRENT_IMAGE should NOT be uploaded. However, it still needs to be renamed (to "image.jpg") so the WebUI and Allsky Website can find it. Note that line 184 does Does that make sense? |
Beta Was this translation helpful? Give feedback.
-
Yes! Thank you very much Eric, for answering my questions. The reason for wanting the formatted date is that at some point a human may look at the files and a 14-digit numerical string is hard to decode at a glance, while inserting some formatting in the right places helps considerably. All the various astronomical files I process are created with this formatting in their filename and I wanted to keep the same convention for the all-sky camera images too. Yes, there are 2 copies of the files - at least for a short time. We don't regard a Pi as an archiving computer, so those files are automatically deleted after a week, but the Windows PC files are actually then archived onto a larger server along with the other data taken during the night. If I'm the only person wanting this formatting in the filename, plus wanting dynamic file names, then there is little point in forcing the change. It is trivial to insert the line I previously used into saveImage.sh, which is what I've now done and it works fine. (I had hoped that with all the changes that have happened recently that the "local" upload system could accommodate this.) The problem with this is that the date & time string which I use is for when the file is processed, which is a few seconds after the proper time of the image readout, so I now need to brush up even more on my bash scripting to see if I can format the string extracted from the filename rather than inserting a new string which is out by a few seconds. |
Beta Was this translation helpful? Give feedback.
-
@KMBlundell, I'll implement the ability to have the uploaded file retain its YYYYMMDDHHMMSS name since it's fairly simple. It will be in the next release which we're almost ready for user testing. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I need some help in upgrading from an old version to the latest version of the allsky package. I've been using the system since version 0.6 but it seemed worthwhile to update as there have been some very useful changes made. I have installed 0.8.3.3 on a new Pi4 and have everything working perfectly, so there is no problem with standard operations - my problem is that I have been running 0.6 (and 0.7) with a small tweak, and think that now there may be a better way to do this with the recent improvements to the system. Let me explain what I've been doing and why (sorry if this is a bit long!).
I have the Pi on the same (secure) network as the observing (Windows) computer and set them up with a shared directory. By simply copying the current image into this shared space on the Pi allowed the observing computer to see (and archive) the latest image. (This avoids the unnecessary step of setting up an FTP server.) The latest image was given a unique name by appending the date and time to a base name. Irfanview was configured to "watch" the directory and automatically display any new image. This worked perfectly - except it required adding a line into one of the scripts, so it wasn't exactly a portable configuration change and required effort to maintain when changing versions. The additional line was:
cp $CURRENT_IMAGE "Windows-share/$FILENAME-$(date+'%Y-%m-%d_%H-%M-%S').$EXTENSION"
I thought that I could use the upload option in the new system now that it has a local option intended for updating a local web server. But this only copies image.jpg and overwrites it each time, which is not what I want. Is there a way to modify the copied filename by appending the date and time - in the same way that movies, startrails & keograms can be renamed (parameter in ftp-settings.sh - although I think this only supports a static name)? Is this a new feature request or is there a way to do it already?
At the moment, I have modified upload.sh to break DESTINATION_FILE into the filename and extension and then add the date & time back into a modified DESTINATION_FILE to give a unique name - but I can't get the hyphens in the date to appear as I did before, so the date and time string just becomes a continuous number sequence. I don't know if this because the new Pi is running bullseye and the old one is running buster and there's been some weird change, or whether my bash shell programming skills are not up to the job (most likely). The following lines are what I've inserted and don't quite work - can somebody please tell me why the hyphens don't appear in the filename:
I note that the images saved in the dated directories don't have hyphens between the fields either. What governs this naming convention and can it be changed?
In going through the scripts to try to follow what is happening I came across this apparent duplication which I don't understand. The following are selected lines from the saveimage.sh script:
Line 182 (executed only if upload=true) appears to be identiical to line 213 which is always executed.
I also don't understand why the same file is being given multiple identities. I find this very confusing when trying to understand what is going on.
It would be greatly appreciated if somebody can answer these questions. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions