Jump to content

sgl_imaging_challenge_2021_annual.thumb.jpg.3fc34f695a81b16210333189a3162ac7.jpg

A couple of scripts I wrote to help processing


Recommended Posts

Two useful scripts to use when playing with many files / avi and mosiacs.

Copy the code and paste it into notepad and call it something.vbs

PLEASE TEST THEM FIRST ON DUMMY DATA. I AM NOT RESPONSIBLE IF IT DELETES / CHANGES REAL DATA

If you struggle with what VBScript is or how scripts work in general, please do not play with these.

Have fun...

Playing around with Registax, I realised that if I wanted to batch process many files, then I would need to create the batch file and load it into Registax.

Well for 3 or 4 avi's not a problem, but for 50+ ..... mmmm, a lot of copy and pasting...

Here is a script to help with instructions on the top

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
'' Copyright Catanonia 2010
''
''
''
'' Script file for creating Registax batch files (r5b)
''
'' Variables that need to be complete are below
''
'' strPath = The directory of your AVI files
'' strName = The common name of the AVI files without the xxxxx
'' nCount = How many files you have minus 1
'' nLimit = Registax LIMIT value for the no of stacked images
'' strOutFile = The output file
''
'' Notes
''
'' You must have your files named as OBJECT_XXXXX.AVI ie moon00001.avi -> moon00100.avi
'' You must have a registax alignment file call OBJECT_00000.RAP ie moon_00000.RAP and it must be in your AVI directory
'' Files are exported from Registax as .TIF files
''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim strPath
Dim strName
Dim nCount
Dim nLimit
Dim strOutFile

strOutFile = "C:\RegistaxCat.r5b"
strPath = "D:\Barlows\"
strName = "Moon"
nLimit = 50

nCount = 105
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strOutFile, 2, 1)
for i = 0 to nCount - 1
objFile.WriteLine("SELECT " + strPath + strName + "_" + CStr(PadDigits(i, 5)) + ".AVI")
objFile.WriteLine("LOADRAP " + strName + "_00000.RAP")
objFile.WriteLine("ALIGN")
objFile.WriteLine("LIMIT " + CStr(nLimit))
objFile.WriteLine("OPTIMIZE")
objFile.WriteLine("STACK")
objFile.WriteLine("SAVESTACK " + strName + CStr(i) + ".tif")
objFile.WriteLine("")
next
objFile.Close

Function PadDigits(n, totalDigits)

PadDigits = Right(String(totalDigits,"0") & n, totalDigits)

End Function

The next problem was with MS ICE the imager merger. What if you had two lots of files with the same names ? Well you can't load multiple directories or folders into ICE so the only way was to labourously copy and rename one of the folders with new file names. Again a problem with 50+ files.

Here is some code that appends a set of characters to the front of the file name in the supplied directory to make them unique.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
'' Copyright Catanonia 2010
''
''
''
'' Script file for renaming files in a directoy with a preceeding number of characters
''
'' Variables that need to be complete are below
''
'' sFolder = The directory of your files without the backspace
'' sAddChar = The characters to be aded to the front of each file
'' Notes
''
'' eg FileListAppend "c:\temp" "TEST"
''
''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

On Error Resume Next
Dim fso, folder, files, sFolder, iCount
Dim pFileArray(3000)
Set fso = CreateObject("Scripting.FileSystemObject")
sFolder = Wscript.Arguments.Item(0)
sAddChar = Wscript.Arguments.Item(1)

If sFolder = "" Then
Wscript.Echo "No Folder parameter was passed"
Wscript.Quit
End If
If sAddChar = "" Then
Wscript.Echo "No addition character was passed"
Wscript.Quit
End If
Set folder = fso.GetFolder(sFolder)
Set files = folder.Files
''
'' Get the list of files into the array
''
iCount = 0
For each folderIdx In files
pFileArray(iCount) = folderIdx.Name
icount = iCount + 1
Next
''
'' Rename the files
''
For i = 0 to iCount - 1
fso.MoveFile sFolder + "\" + pFileArray(i), sFolder + "\" + sAddChar + pFileArray(i)
Next
Edited by Catanonia
Link to comment
Share on other sites

Cheers!! That looks incredibly handy.

Please be careful with them and test on dummy data.

Currently writing a new script to take files and rename them sequencially such as moon_00001 etc etc to give nice ordering.

Watch out with registax, it doesn't like long directory names in its batch files.

Edited by Catanonia
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
 Share

  • 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.