Hi, I'm looking for a way to optimize a script I'm currently working on.
It's purpose is to sort files into alphabetical subfolders. Which basically means that I have to use the same code block 26 times for each (normal) letter. I already have a code block which relies on a variable and therefore it does not have to be altered for each letter. In a bash script I simply could turn that block into a function. Which makes the code easier to change (just one block instead of 26) and it would be much smaller.
The code block looks like this:
Code:
SET Letter "A"
LIST >>T:AlphaSort.${Letter} FILES "${Source}" PAT="${Letter}~(.info)" LFORMAT="${Command} *"%P%N*" *"${Target}${Letter}/*"*nECHO *"*E[43m *E[40m*" NOLINE"
ECHO "*E[43m *E[40m" NOLINE
IF "empty" EQ "`ECHO "*`LIST FILES "T:AlphaSort.${Letter}" LFORMAT="%L"*`" NOLINE`"
DELETE >NIL: "T:AlphaSort.${Letter}"
ELSE
ECHO >>T:AlphaSort.EXE "ECHO *"${Action}: ${Letter}#? to ${Target}${Letter}/... *" NOLINE"
ECHO >>T:AlphaSort.EXE "MAKEDIR >NIL: ${Target}${Letter}"
TYPE T:AlphaSort.${Letter} >>T:AlphaSort.EXE
ECHO >>T:AlphaSort.EXE "ECHO *" Done.*""
ENDIF
First the starting letter is set and then all operations are done based around that letter.
I'll attach the current version of the script, so you can check it out completely.
I added the .s extension for it to be a valid file but it is just a normal text based shell script.
Edit: Removed this version. See below for newer version.