WatchDirectory home page
WatchDirectory Startseite (Deutsche Version)
Site WatchDirectory (Français)
  Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
   
  HomeHelpSearchLoginRegister  
 
Page Index Toggle Pages: 1
Copy jpg and xml files when filetitles match (Read 3020 times)
jimaus
Junior Member
**
Offline



Posts: 59
Australia
Copy jpg and xml files when filetitles match
Oct 24th, 2011 at 7:08am
 
Hi Gert,

We have a 2 processes on our graphics server which exports a jpg and an xml file with the same file title, eg jim.jpg and jim.xml.

The processes do not run at the same time, sometimes there is as much as 5 minutes between the creation of one and the creation of the other.
The resulting files are picked up by a process which will flush the xml file if the jpg is not present

I am trying to work out how to move the 2 file but only when both are present. So that I do not get a lot of unnecessarily flushed files.
I would have the processes create the files in a temp location, then have WD move them when they both are present.

Any thoughts?
Cheers
Jim
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Copy jpg and xml files when filetitles match
Reply #1 - Oct 24th, 2011 at 8:04am
 
Hello Jim,

The following (untested) script should do the trick.
[code]rem this script is called for the XML file
rem it waits until the corresponding JPG file is present
rem and moves both files to TARGET

rem when both files are ready, where should they be moved to?
SET TARGET=C:\Target
rem how long to sleep between checks?
SET SLEEP=3


SET OTHERFILE=%WD_FILE_D%%WD_FILE_B%.jpg
SET GDPUTIL=%WD_INSTDIR%\GdPUtil.exe

SET COUNT=0
:CheckAgain
SET /a COUNT=%COUNT% + 1
IF %COUNT% GEQ 20 GOTO :ErrorNotFound

IF EXIST "%OTHERFILE%" GOTO :BothFound

rem sleep a bit before checking again
"%GDPUTIL%" -sleep %SLEEP%
GOTO :CheckAgain

:BothFound
rem 1 extra sleep to make sure the jpg is ready
"%GDPUTIL%" -sleep %SLEEP%
MOVE "%WD_FILE%" "%TARGET%"
MOVE "%OTHERFILE%" "%TARGET%"
GOTO :EOF

:ErrorNotFound
echo the jpg was not created in time
GOTO :EOF

[/code]
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Copy jpg and xml files when filetitles match
Reply #2 - Oct 24th, 2011 at 8:07am
 
I now see it only waits ~60 seconds (20 times 3 seconds).

You may want to change line 17.
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Copy jpg and xml files when filetitles match
Reply #3 - Oct 24th, 2011 at 8:18am
 
you may also want to switch the 2 move statements so the JPG is first moved to the target directory.
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
jimaus
Junior Member
**
Offline



Posts: 59
Australia
Re: Copy jpg and xml files when filetitles match
Reply #4 - Oct 25th, 2011 at 2:42am
 
Gert,

Thanks for the script, configured and running with no problem.

The comments within made it easy to setup.

Once again excellent service.

Cheers
jim
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1