jmj4331 Posted January 12, 2017 Share Posted January 12, 2017 (edited) Hi All, I have a directory that will continually get populated with PDF files. Any files that over 24 hours will automatically be deleted. The file name will be in this type of format: "zzztest, ann_01122017065226.pdf" I'm not concerned with who's name is in the file name, what I am trying to do is pull the ending date and time, out of the file name. Which I have done successfully. When my program gets to the part where I want to dissect the date and flip it to yyyy/mm/dd format, the string I send IsArray() does not work. Here is the code snippet: $sFileName = String(FileFindNextFile($hFile)) $sNewFile = StringTrimRight($sFileName, 4) $sFileName = StringRight($sNewFile, 14) $aTime = StringRight($sFileName, 6) $aDate = StringTrimRight($sFilename, 6) $aDate = '"' & $aDate & '"' MsgBox(0, "", $aDate, 2) If IsArray($aDate) Then $iMon = Number($aDate[3]); [0] for Year when $aFDate MsgBox(0, "", $iMon,2) $iDay = Number($aDate[4]); [1] for Month when $aFDate MsgBox(0, "", $iDay,2) $iYear = Number($aDate[5]); [2] for Day when $aFDate MsgBox(0, "", $iYear,2) Else Msgbox(0, "", "Not an array", 2) EndIf As you can see I tried adding in quotes. Is there something else I need to do with this file name to get IsArray to recognize it as an array? Thanks, -Jeff Edited January 12, 2017 by JLogan3o13 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 12, 2017 Moderators Share Posted January 12, 2017 Not sure why everyone posts in Developer forum first time; moved to General Help and Support. @jmj4331 welcome to the forum. Please use code tags <> when you post code, makes it much easier to read. I have done so for you in your initial post. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
anthonyjr2 Posted January 12, 2017 Share Posted January 12, 2017 Melba's Date_Time_Convert UDF should be able to do the conversion for you: That way you don't have to mess around with it yourself. UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI= Link to comment Share on other sites More sharing options...
mikell Posted January 12, 2017 Share Posted January 12, 2017 If $aDate displays in a Msgbox, then it is a string, not an array. BTW the correct naming (prefix) should be here $sDate But you don't need to go the array way. There is a nice example in the helpfile for the func StringRegExpReplace Using this example, to fit your needs this could be done $sFileName = "zzztest, ann_01122017065226.pdf" $sDate = StringRegExpReplace($sFileName, '.*(\d{2})(\d{2})(\d{4})\d{6}.pdf', "$3/$2/$1") Msgbox(0, "", $sDate) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now