The line to clear out the file clears out all files!
change it to a simple file.remove() by using your very first 'file' variable.
Put that into line 52 and remove the ones below.
Btw, how does your hotfolder work? How does it know to run this script when a file is dropped in?
I'm on a Windows 7 Machine.. so I use an app called Folder Actions for Windows... Once I assign a folder to be watched, it runs a .bat file to open Illustrator and run any specific script I list. It's pretty slick and works great...
The contents of the .bat file are simple... Just go to the basic notepad app and insert the following text line. just remember to save with a .bat as the extension. In some cases you may need to go to the Folder Actions window > View Tab and uncheck the hide extenstions for known file types. This way you can remove the default. txt the program wants to add..
"C:\Program Files\Adobe\Adobe Illustrator CC 2017\Support Files\Contents\Windows\Illustrator.exe" C:\Program Files\Adobe\Adobe Illustrator CC 2017\Presets\en_US\Scripts\***Your SCRIPT HERE*****.jsx
So to make sure I'm understanding you... If I replace everything I have from line 52 to the end with the file.remove() the script will cycle through until all of them are processed?
No, I guess it should be really re-written so that the code is inside of a loop. The stuff after line 52 removes all the files, I guess it could be left alone and be ran right where it's at after the main loop completes. I was originally thinking your folder action could run a single-action script over all the files, if it worked that way. But if the actions are ok with multiple files dropped in (as in, it only calls the script after all the files are placed in, not one time for every placed file separately), then one loop can be used in the script.
This is a great exercise on code building, you can write down your steps and make some pseudo-code flowchart to help.
Also curious about your hot folder workings. Does it automatically open illustrator, execute script(s) and then remove the file from the folder? Or is it a folder that fills up with a few documents and then you manually run a script that processes all the files in that folder?
As to your clarification question, it's lines 55-60 that are giving you trouble. You're processing one file out of the folder, then running a for loop to delete every file in the folder. So you either need to have the script process each file in the folder before you run a loop to remove each file, or you need to lose the loop and instead simply use what Silly said above and just do a simple remove on the individual file that you just finished processing.
Let's go for the latter option. When you're writing these scripts, keep an eye out for repetition/redundancy. Anything you type more than once, can typically be reused instead of retyped. in the above script, lines 3 and 4 are identical to lines 56 and 57. You've already declared variables for your hot folder and the files inside. So you don't need to do those again. You already set a variable, "file", to the file you want to remove. So you simply need to use: file.remove() as silly said above.
One thing on which i don't agree with Silly however, is removing line 52. I think that's an important part. I would simply add :
to line 54 and call it a day. You should be all set after that.