我正在寻找方法来移动基于英国财政年度的文件(从4月6日至4月5日)。文件在模式中命名为
2014-08-26_Asda_lunch.pdf
2016-03-20_Tesco_sationary.pdf文件需要移动到命名的文件夹,等等
FY 2014-15
FY 2015-16只是想知道applescript/ shell脚本或automator操作是否有助于实现这一目标。还有,与榛子的接口更好
谢谢,我已经试过修改脚本了
我的第一个目标是正确的月份,然后尝试日期;脚本文件2019-07-26_Tesco_ -> _ Script 2020 (预期2019年-20财政年度)的输出文件2019-03-15_Sainsbury -> FY 2019 (预计2018-19财政年)请提供建议,还有任何添加日期的指针,以帮助您进行分类。
set savedDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"-"}
tell application "Finder"
set filename to name of theFile
end tell
set expenseYear to (first text item of filename) as number
set expenseMonth to (second text item of filename) as number
set expenseDate to (third text item of filename) as number
-- Get the last two characters of the Year
set AppleScript's text item delimiters to savedDelimiters
set lastTwoCharactersOfYear to (characters 3 thru 4 of (expenseYear as text))
set RoundedExpYear to (lastTwoCharactersOfYear as text) as number
if expenseMonth ≥ 4 then
set LongString to expenseYear
set ShortString to RoundedExpYear + 1
else
set LongString to expenseYear - 1
set ShortString to RoundedExpYear
end if
set returnText to "FY" & " " & LongString & "-" & ShortString发布于 2020-09-30 06:16:33
解析日期的方法很多,但是由于您的格式总是相同的(),所以我使用了最简单的方法。在处理程序下面的脚本中,当您给出参数文件名时,GetFY直接返回您要查找的“”格式:
set Fname to "2014-03-05_xxxx" -- value to test
set myfolder to GetFy(Fname)
log "myfolder=" & myfolder
on GetFy(Fname) -- return FY-(FY+1) based on Fname as YYYY-MM-DD_xxxxxx
set myear to (text 1 thru 4 of Fname) as integer
set mmonth to (text 6 thru 7 of Fname) as integer
set mday to (text 9 thru 10 of Fname) as integer
if mmonth < 4 then set Fy to myear - 1
if mmonth = 4 then set Fy to myear - ((mday ≤ 5) as integer)
if mmonth > 4 then set Fy to myear
return "FY " & Fy & "-" & (Fy + 1)
end GetFyhttps://stackoverflow.com/questions/64129801
复制相似问题