Jump to content

SkySurveyBanner.jpg.21855908fce40597655603b6c9af720d.jpg

Any DOS experts here?


BrendanC

Recommended Posts

Hi all,

I find it very much easier when processing my images, to have all my files sorted into files by temperature.

However, I've decided I find it tedious! And it's such a mechanistic process, I'm sure it could be automated using a .BAT file.

It would do this:

1. Start in the current folder

2. Set a counter to 1

3. Look for files with '1C 'in the name

4. If there's at least one file, make a folder called 1C and move them all to it, if not then do nothing

4. Increment the counter and repeat, to look for 2C, 3C etc until, say, 30C (yes, I do have some files at that temperature believe it or not - non-cooled DSLR during height of summer) 

So instead of having to do this all myself, I could just run, say, sort.bat and it would do it all for me.

I think it's probably fairly simple if you know what you're doing. I've dabbled in code in the past and have looked around for examples, but can't really find anything I could adapt without spending frustrating hours/days/weeks/months/years/decades/centuries/millennia/epochs/aeons getting it wrong.

So, does anyone have anything like this already, or any DOS gurus willing to have a go?

Thanks, Brendan

 

 

Edited by BrendanC
Link to comment
Share on other sites

I'm no expert in scripting languages, but if no-one else offers a script, I can write one using C++, either as a CLI version that should run on any OS, or if you just use Windows, with a Windows GUI front end to make it more friendly to use.  🙂

Alan

Link to comment
Share on other sites

Thank you Alan, that's very kind of you! I daresay other people might find such a script useful too.

No need to go ahead just yet (unless of course you want to), let's see if anyone has something 'pre-baked' as it were. I might also have another stab at doing it myself. I'll let you know how I get on.

Thanks again. :)

Link to comment
Share on other sites

4 hours ago, BrendanC said:

Possibly! I just want a quick, easy utility that would do this. I know batch files can, and shell scripts. No idea about Python.

If you're happy with batch files and shell scripts, surely Powershell will make you feel right at home. VS Code for the IDE, you can run multiple languages with that.

Link to comment
Share on other sites

Hi Brendan,

To amuse myself I've written a cheap and cheerful program 🙂 that should do what you want.

It looks for a 'C' character in the filename and works backwards until it finds a character which is not a number or a minus sign. If the result contains a number it creates a subdirectory named 'Temp_12C' for example and moves the file into it. If the filename happens to contain a number followed by C which is possibly in the filename as a target name, it will take this as a temperature. Surrounding the temperature with underscores or possibly spaces in the filename would make it more robust in picking the temperature correctly.

It's a CLI program so works from a 'DOS' screen though the easiest way to use it is to copy the program into the folder containing your image files and just double clicking on it. The DOS box flashes for an instant and then your files will all be moved into their temperature subdirectories.

The program works on the current directory so if you want to run it from a DOS window, go to the directory where your image files are are and type the full path and filename name to the TempSort.exe program. This will list all the files found and whether they were moved. I could have had the image file directory passed to the program on the command line but it's no quicker really so left it as the current directory as the working directory. It doesn't search through subdirectories for image files as it stands, and assumes they are all in the same directory to start with. 

I can make any changes if you wish, like it's picking up files you don't want it to for example. For testing it I recommend you copy some of your image folders to a test area and work on them there just to check nothing untoward happens. No files are deleted, just renamed with from, to parameters causing them to move (if it's possible to do so) so no data should be at risk, but I have to say to use it at your own risk to absolve myself. 😊 Here's the program

TempSort.exe

Here's the C++ program listing from Visual Studio if you want to see it.  😉 It's fairly small as you can see. Hope you're happy with it.

TempSort.png.d7f9fa3d1ef988fb364e122992168bcf.png

Alan

Edit : I assumed your temperatures were in whole numbers as in your first post. If you wanted decimal degrees included It just needs a small alteration to the program. Can you spot where in the listing? 😀

Edited by symmetal
  • Thanks 1
Link to comment
Share on other sites

Works like a charm! I'm going to test it a lot more before I let it loose on my files, but I've run a few already, made sure it can distinguish 1C from 10C etc, and it's really fast and does exactly what I want.

The only request is, could the folders just be called eg 12C rather than Temp_12C? It would just fit into my system better. Very small thing really, but while I've got the chance, it would be great to get this bit sorted.

Thank you again! Really, really appreciate it. :)

Link to comment
Share on other sites

Glad it worked for you Brendan.

I've removed the Temp_ from the directory names as you requested. The program is a bit larger now as on rebuilding using static libraries as I thought I had before (so you don't need extra .dll files included) it stated that extra libraries need to be downloaded from Microsoft to enable this which I did. It's now added some static libraries to the executable. Anyway, here it is without the Temp_ 

TempSort.exe

Alan

  • Thanks 1
Link to comment
Share on other sites

Glad to help Brendan. 😀 

I've just noticed that the program as it is will detect '-C' in the filename as being a temperature, as I've included '-' as a temperature character, in order to detect minus temperatures, although you didn't request minus temps in your initial post. If you think this may cause an issue, let me know, and I can modify it slightly so that an actual number must appear in front of the 'C' character, before the sub-string will be treated as a temperature value. 🙂

Also, you may prefer the temperature sub-folders to have a more consistant format, where there are always two numbers before the C, like 02C, 08C, 10C. This will then show them in ascending order in the folder, if alphabetically listed.

Alan

Edited by symmetal
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.