I tried the following command (which works in powershell window)
system('powershell -command \"Get-ChildItem -Filter "*.html" | Where-Object { $_.LastWriteTime -ge "11/12/2021 09:10:00" }\"')
However, from the R console I get the error:
At line:1 char:79
+ ... er *.html | Where-Object { $_.LastWriteTime -ge 11/12/2021 09:10:00 }
+ ~~~~~~~~
Unexpected token '09:10:00' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
[1] 1
EDIT
Using Mikael Jagan's idea I managed to get a result:
system(paste('powershell -command ',shQuote('Get-ChildItem -Filter "*.html" | Where-Object { $_.LastWriteTime -ge "11/30/2021 09:10:00" }')))
However, as you see below, the result is a character vector rather a dataframe. Is there a way to get only a vector with the filenames?
[1] ""
[2] ""
[3] " Directory: C:\\Users\\user\\Documents\\R_Data\\texk"
[4] ""
[5] ""
[6] "Mode LastWriteTime Length Name "
[7] "---- ------------- ------ ---- "
[8] "-a---- 30/11/2021 10:31 386751 auth_cash_flow.html "
[9] "-a---- 30/11/2021 10:31 189370 auth_cash_flow_total.html "
[10] "-a---- 30/11/2021 10:31 552947 auth_symv_gantt.html "
[11] "-a---- 30/11/2021 10:31 93238 auth_tender_schedule.html "
[12] "-a---- 30/11/2021 10:30 683088 dev_constr_pivot.html "
[13] "-a---- 30/11/2021 10:30 70224 form_org_chart.html "
[14] "-a---- 30/11/2021 10:31 199907 form_org_chart2.html "
[15] "-a---- 30/11/2021 10:30 618821 form_workload.html "
[16] "-a---- 30/11/2021 10:30 109127 index.html "
[17] ""
[18] ""
This is my session info:
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=Greek_Greece.1253 LC_CTYPE=Greek_Greece.1253 LC_MONETARY=Greek_Greece.1253
[4] LC_NUMERIC=C LC_TIME=Greek_Greece.1253
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.5 tools_4.0.5
file.info.shQuote. There are Windows-specific examples in?shQuotethat you should try, if only to see what works. (Deleting my initial comment, which contains a typo anyway, to avoid clutter.)x <- file.info(list.files(pattern = "*.html")); x[ as.Date(x$mtime) > as.Date("2021-11-01"), ]