Move file to a folder

Scripts and programs to automate Astroart
Post Reply
User avatar
Rudi
Posts: 160
Joined: 08 Jan 2019, 04:47

Move file to a folder

Post by Rudi » 01 Mar 2019, 15:23

Is there a script function that moves a file to another folder?

I have gathered hundrets of fits files over four observation nights under poor conditions with haze and clouds.
I want to filter away lights with "too bright" background (ADU > 500 in my case).

It's tedious to do this manually, so I wanted to script it. However, I cant seem to find a way of moving a file to another folder.
Or even renaming a file, that's another question. I can rename an image and save it, but then I end up with the same image with two different names, since I cant find a way to delete a file.

However, the script below eases the work, it gives me a list of files that I then can move manually.

Code: Select all

' root folder nad list of files to examine
folder = "C:\Users\Bruger\Rudi Dropbox\Main\astro\2019\0227\"
fitsFiles = FindFiles(folder, "cone*.fit")

' max image background ADU accepted
maxBackADU = 500


' get the number of files to examine
N = Count(fitsFiles)
for i = 1 to N

    ' open image and get background ADU
    Image.Open(folder + fitsFiles{i})
    bckADU = Image.Background

    ' is the maximum backgound ADU exceeded?
    if maxBackADU < bckADU then
        s = fitsFiles{i}
        s = s + ", background value = "
        s = s + Str(Image.Background)
        print s

        ' todo... move file to a folder for bad images
    endif
    Image.Close()
next i
/Rudi

fabdev
Posts: 502
Joined: 03 Dec 2018, 21:43

Re: Move file to a folder

Post by fabdev » 01 Mar 2019, 23:29

Hello, a script command "DeleteFile" will be added to Service Pack 1, in 2-3 months.
meanwhile you could "delete" an image this way:

Image.Resize(16,16)
Image.Save( <filename..> )

Doing so the "deleted" files will be very small, and you will be able to delete all them at once from Windows.

User avatar
Rudi
Posts: 160
Joined: 08 Jan 2019, 04:47

Re: Move file to a folder

Post by Rudi » 02 Mar 2019, 09:31

Thanks Fabio 👍
/Rudi

Post Reply