I'm needing to search a networked folder for the latest created files, parse the name of that file, and start processing several different functions based on the parsed information.
Our file naming convention will be:
yyyy.MM.dd-dddtt-seriesMSG-title-name.*
yyyy.MM.dd = Date
ddd = Day of the Week
tt = AM / PM
series = Running Series of Titles (sometimes exists, but is needed to build a special collection if it does exist)
MSG = Which message in the Running Series (see item above)
title = Message Title (exists about 90% of the time)
name = Full name of the person giving the message
File type to search for will be .JPG
File type to create based off of the above information will be .MP3, .RPP, and .PDF (maybe others later on including adding information to a spreadsheet).
I'm not sure which way would be better... to read each filename in and parse the yyyy.MM.dd and the tt to see which is the latest file to parse (which would then have the rest of the data parts already filled in, probably into an object array), or to look up the file create date / time and then parse the data segments into simple variables (can AHK do this?).
I'm still somewhat of a novice to AHK and am looking for a direction to start studying and building on. I'd rather seek advice on this than to stumble and waste time.
Many thanks in advance for your consideration in helping out.
TXShooter
Needing advice on Searching for Files
Re: Needing advice on Searching for Files
So, there's no delimiter between "series" and "MSG"? Would you mind to provide a few (3-5) sample names besides the name spec itself??
Re: Needing advice on Searching for Files
yyyy.MM.dd = Date ; OK
ddd = Day of the Week ; OK
tt = AM / PM ; OK, nevertheless I'd go with 24h format to be more specific
series = Running Series of Titles (sometimes exists, but is needed to build a special collection if it does exist) ; the problematic part. If not existing, will its 'column' stay empty or isn't it existing as well ?
MSG = Which message in the Running Series (see item above) ; ?? (waiting for a sample filename to clarify)
title = Message Title (exists about 90% of the time) ; see 'series' above
name = Full name of the person giving the message ; OK
Code: Select all
name := "2018.01.17-THUAM-series-MSG-blabla-Mr.Poop"
array := StrSplit(name,"-")
MsgBox % Date := array[1] "`n"
. WeekDay := SubStr(array[2],1,3) "`n"
. Time := SubStr(array[2],4,2) "`n"
. Series := array[3] "`n"
. MSG := array[4] "`n"
. Title := array[5] "`n"
. Name := array[6]
Re: Needing advice on Searching for Files
I'm not sure my preacher needs to be humbled that much, but this ought to do it. lolBoBo wrote:name := "2018.01.17-THUAM-series-MSG-blabla-Mr.Poop"yyyy.MM.dd = Date ; OK
ddd = Day of the Week ; OK
tt = AM / PM ; OK, nevertheless I'd go with 24h format to be more specificActually, I need this to be capable of AM / PM / and SS now that I think about it, so neither 24HR and tt will work.
series = Running Series of Titles (sometimes exists, but is needed to build a special collection if it does exist) ; the problematic part. If not existing, will its 'column' stay empty or isn't it existing as well ?A blank is acceptable.
MSG = Which message in the Running Series (see item above) ; ?? (waiting for a sample filename to clarify)
2017.12.13-Wed PM-The Fruitful Christian Life-Msg02-True Vine-Pastor Bob
2017.12.17-Sun AM-(not a series)-(no MSG number)-Where Do I Go From Here-Pastor Frank<= This is most typical, except without the parenthesis parts.
title = Message Title (exists about 90% of the time) ; see 'series' above
name = Full name of the person giving the message ; OK
The more that I think about this, the more it might be better to just simply read in every filename and parse each one, updating the spreadsheet if need be should something change.
Thank you for your input.
- divanebaba
- Posts: 805
- Joined: 20 Dec 2016, 03:53
- Location: Diaspora
Re: Needing advice on Searching for Files
Easy way to find the last created file is a loop (for files) with getting A_LoopFileTimeCreated or last modified A_LoopFileTimeModified.TXShooter wrote:I'm needing to search a networked folder for the latest created files, ...
Adding A_LoopFileTimeModified prior to filenames in the list, makes it possible to sort.
Now you just have to read out the first line of the sorted list, trim the added timestamp and you have your last created (or modified) file.
Code: Select all
FileList =
Loop, Files, N:\myNetworkFiles\myNetworkFolder\*.* ; put in your path here
FileList=%FileList%%A_LoopFileTimeModified%_%A_LoopFileFullPath%`n ; Creating a list with A_LoopFileTimeModified_ in prior to filename (A_LoopFileFullPath)
Sort, FileList, N R ; self explaining
msgbox % FileList
Loop, parse, FileList, `n, `r ; parsing loop to get first row of the list (FileList))
{
Stringtrimleft, myNewestFile, A_LoopField, 15 ; timestamp has 14 chars an underline another.
break ; breaking after first pass ensures getting first row
}
msgbox % myNewestFile
Einfach nur ein toller Typ.
Who is online
Users browsing this forum: KruschenZ and 61 guests