AutoHotkey Community

It is currently May 27th, 2012, 10:28 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: September 20th, 2007, 5:19 pm 
Offline

Joined: September 16th, 2006, 5:34 am
Posts: 27
I am wanting to write a script that periodically polls a folder for files of a specific extension. When it finds one (or several), it executes a command on that file, waits for it to complete, checks for an output file, and renames the original based on whether or not the output exists. It then loops back and repeats the process. I don't want to get into a massive loop, so it would need to pause for 15 minutes before checking again if there is nothing to process. You wouldn't think this would be too difficult, but I'm having issues. The whole thing is giving me a headache. If I look real pitiful, can someone point me in the right direction?
D.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 20th, 2007, 6:14 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
Good place to start:
Crazy Scripting : FolderSpy v0.96

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 20th, 2007, 7:10 pm 
Offline

Joined: September 16th, 2006, 5:34 am
Posts: 27
My problem stems from the fact that the output that I am looking for has the same file name, but a different extension, from the original file in %A_LoopFileName%. I know I can pull just the extension from %A_LoopFileName%, but how do I pull just the file name, add a new extension, and check if that file exists? If It exists, I want to rename the original as *.done. If the output doesn't exist, I want to rename it as *.err.
D.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 20th, 2007, 7:13 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Try to post some psuedo code .. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 20th, 2007, 7:27 pm 
Offline

Joined: September 16th, 2006, 5:34 am
Posts: 27
Skan wrote:
Try to post some psuedo code .. :)

OK. Suppose %A_LoopFileName% contained "image.flame". This is what I want to do
Code:
Loop, %A_WorkingDir%\*.flame
   {
   RunWait %comspec% /c ""flam3-render.exe" <"%A_LoopFileName%""
If image.jpg exists
     FileMove %A_LoopFileName%,%A_LoopFileName%.done,1
If not, and no error code
     FileMove %A_LoopFileName%,%A_LoopFileName%.done,1
end
   }


If the RunWait is successful, it produces a JPG image. It's rendering a fractal. On success, I want to rename the parameters so they won't be picked up next loop through. If the program completed and no JPG was produced, I want to rename that as well so I can check on why it failed. If someone does a ctrl-c in the process, I just want the program to abort.
D.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 20th, 2007, 7:49 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
The following is not working code .. You have to find and solve the missing pieces.

Code:
#Persistent
SetWorkingDir, ???
TimerTime := 15 * 60 * 1000 ; 15 Minutes
GoSub, CheckRoutine
Return

^C::ExitApp

CheckRoutine:
SetTimer, checkRoutine, OFF

Loop, %A_WorkingDir%\*.flame
  {
   flameFile := A_LoopFileLongPath
   CommandParam=flam3-render.exe < %flameFile%
   RunWait %comspec% /c "%CommandParam%"
   SplitPath, flameFile, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
   jpegFile := OutDir "\" OutNameNoExt "." JPG
   doneFile := OutDir "\" OutNameNoExt "." DONE
   IfExist, %jpegFile%
     FileMove, %flameFile%, %doneFile%, 1
   else
     FileMove, %flameFile%, %doneFile%, 1 ; I am confused over this part!
  }
SetTimer, CheckRoutine, %TimerTime%
Return


:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 20th, 2007, 8:03 pm 
Offline

Joined: September 16th, 2006, 5:34 am
Posts: 27
SplitPath was the piece I was missing! And don't be confused. There would be a DoneFile and an ErrFile. If the JPG exists, we go the DoneFile route. If not, we rename it with a .ERR extension. Thanks for all your help. I was guessing that there was a command to do this, but when you don't know what it is called, sometimes it is hard to find. :)
D.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 20th, 2007, 8:07 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
djeaton3162 wrote:
I was guessing that there was a command to do this, but when you don't know what it is called, sometimes it is hard to find. :)


True. :D
BTW, You can also achieve the same result with RegExMatch()

:)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: chaosad, robotkoer, Yahoo [Bot] and 70 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group