'入力ファイル名が、aaYYMMDDHHmm.pngの１２桁であることが前提。
'
Print "処理開始"
M$="00"                                          '月またがりの判定
K=0
'
*start
ChDir("C:\HRO\HROFFT")
pic_s$=FindFirstFile("*.png")          'PNGファイル名の抽出
While pic_s$=""
   Sleep(10000)                         '休止１０秒
   pic_s$=FindFirstFile("*.png")        'PNGファイル名の抽出
Wend
FindFileClose
'
*jamp0
yy$=Mid$(pic_s$,3,2)                       'ファイル名の分解
mm$=Mid$(pic_s$,5,2)
dd$=Mid$(pic_s$,7,2)
hh$=Mid$(pic_s$,9,2)
f0$=Mid$(pic_s$,11,2)
pic_o1$=pic_s$
'
If M$="00" Then                      '一番最初だけ「月」を格納
   M$=mm$
end if
'
yy=Val(yy$)                               'UTをJSTに変換     
mm=Val(mm$)      
dd=Val(dd$)      
hh=Val(hh$)      
If hh < 15 Then 
   hh=hh+9 
else 
   Call Sub_yymm(mm,yy,frag)             '閏年の処理
   hh=hh+9-24 
   If dd < frag Then
      dd=dd+1 
   else 
      dd=1 
      mm=mm+1
   end If
end If
If mm = 13 Then 
   mm=1
   yy=yy+1
end If
'
yy$=Str$(yy)                          'ファイル名作成
yy$=LTrim$(yy$)
mm$=Str$(mm)
If mm<10 then
   mm$="0"+LTrim$(mm$)
else
   mm$=LTrim$(mm$)
end If
dd$=Str$(dd)
If dd<10 then
   dd$="0"+LTrim$(dd$)
else
   dd$=LTrim$(dd$)
end If
hh$=Str$(hh)
If hh<10 then
   hh$="0"+LTrim$(hh$)
else
   hh$=LTrim$(hh$)
end If
'
pic_o2$=yy$+mm$+dd$+hh$+f0$+".png"      'JST用ファイルの作成
'
For I =1 To 3
   If RenameFile (pic_s$,pic_o2$) Then
      Goto *jamp1
   else
      Print Date$;" ";GetHour;":";GetMinute;"'";GetSecond;"    ReName NG pic_o2$",I
      Sleep(1000)                                         '休止１秒
   end if
Next
Print Date$;" ";GetHour;":";GetMinute;"'";GetSecond;"    ReName失敗   ";pic_s$,pic_o2$
End
'
*jamp1
FileCopy pic_o2$,"C:\HRO\HRO-Data\"    'JST用ファイルを転送
'
FileCopy pic_o2$,"C:\HRO\Color-Data\"      'Colorgrammeへファイルを転送
If DeleteFile(pic_o2$) Then 
Else
   Print "削除に失敗 pic_o2$",pic_o2$
   End
End If
'
ChDir("C:\HRO\Color-Data")
'
For I =1 To 3
   If RenameFile (pic_o2$,pic_o1$) Then
      Goto *jamp2
   else
      Print Date$;" ";GetHour;":";GetMinute;"'";GetSecond;"    ReName NG pic_o1$",I
      Sleep(1000)                                         '休止１秒
   end if
Next
Print Date$;" ";GetHour;":";GetMinute;"'";GetSecond;"    ReName失敗   ";pic_o2$,pic_o1$
End
'
*jamp2
ChDir("C:\HRO\HROFFT")
'
pic_s$=FindFirstFile("*.png")                            '次のPNGファイル名の抽出
While pic_s$<>""
   Goto *jamp0
Wend
FindFileClose
'
'-----Colorgramme用ファイルの 削除　ルーチン
ChDir("C:\HRO\Color-Data")
'
For I =1 To 8                                        '休止80秒
Sleep(10000) 
Next
'
pic_o1$=FindFirstFile("*.png")          'PNGファイル名の抽出
While pic_o1$<>""
'   mm$=Mid$(pic_o1$,3,2)
'   If M$=mm$ Then                      '同じ「月」なら削除処理へ
      If DeleteFile(pic_o1$) Then 
      Else
         Print "削除に失敗 pic_o1$",pic_o1$
         End
      End If
'   Else
'      Goto *finsh
'   End If
   pic_o1$=FindNextFile                  '次のPNGファイル名の抽出
Wend
'
*finsh
FindFileClose
Goto *start
'
'
'--------- Sub ルーチン
Sub Sub_yymm(mm,yy,frag)                '月日処理
If mm=1 then
   frag=31
end if
If mm=2 then
   yy_y=yy mod 4                        '閏年の判定
   If yy_y=0 then
      frag=29
   else
      frag=28 
   end if      
end if
If mm=3 then
   frag=31
end if
If mm=4 then
   frag=30
end if
If mm=5 then
   frag=31
end if
If mm=6 then
   frag=30
end if
If mm=7 then
   frag=31
end if
If mm=8 then
   frag=31
end if
If mm=9 then
   frag=30
end if
If mm=10 then
   frag=31
end if
If mm=11 then
   frag=30
end if
If mm=12 then
   frag=31
end if
end sub




