我正在使用shell()
命令從函數內的.tex文件生成pdf文檔。此功能有時會通過調整後的數據運行多次,因此會覆蓋文檔。當然,如果pdf文件在運行.tex文件時打開,它會生成一個錯誤,說明它無法運行.tex文件。所以我想知道是否有任何R或Windows cmd命令來檢查文件是否打開?檢查文件是否使用R內的Windows命令行打開
1
A
回答
1
我並不認爲這是一個很好的解決方案:它很冒險,但也許它會做。您可以複製該文件並嘗試用它覆蓋原始文件。如果失敗,則不會造成傷害。如果成功,您將修改文件的信息(而不是內容),但是由於您的最終目標是無論如何都要覆蓋它,我懷疑這會是一個大問題。無論哪種情況,您都會修改是否可以重寫該文件。如果找到和1+如果沒有找到或錯誤
is.writeable <- function(f) {
tmp <- tempfile()
file.copy(f, tmp)
success <- file.copy(tmp, f)
return(success)
}
0
openfiles /query /v|(findstr /i /c:"C:\Users\David Candy\Documents\Super.xls"&&echo File is open||echo File isn't opened)
輸出
592 David Candy 1756 EXCEL.EXE C:\Users\David Candy\Documents\Super.xls
File is open
Findstr工具返回0。
& seperates commands on a line.
&& executes this command only if previous command's errorlevel is 0.
|| (not used above) executes this command only if previous command's errorlevel is NOT 0
> output to a file
>> append output to a file
< input from a file
| output of one command into the input of another command
^ escapes any of the above, including itself, if needed to be passed to a program
" parameters with spaces must be enclosed in quotes
+ used with copy to concatinate files. E.G. copy file1+file2 newfile
, used with copy to indicate missing parameters. This updates the files modified date. E.G. copy /b file1,,
%variablename% a inbuilt or user set environmental variable
!variablename! a user set environmental variable expanded at execution time, turned with SelLocal EnableDelayedExpansion command
%<number> (%1) the nth command line parameter passed to a batch file. %0 is the batchfile's name.
%* (%*) the entire command line.
%<a letter> or %%<a letter> (%A or %%A) the variable in a for loop. Single % sign at command prompt and double % sign in a batch file.
.
--
相關問題
- 1. 使用命令行打開文件
- 2. Windows命令行打開與命令同名的文件
- 3. 檢查文件是否已經打開
- 4. 如何檢查文件是否打開
- 5. 檢查文件是否打開
- 6. 是否可以在Windows中使用命令行打開命名管道?
- 7. 從命令行使用內部鏈接打開htm文件
- 8. Windows phone 8,檢查wifi是否打開?
- 9. 在Windows XP中,使用C語言:檢查文件是否打開
- 10. 使用批處理或JavaScript來檢查文件是否打開
- 11. HH和打開CHM的命令行選項Windows幫助文件
- 12. 如何檢查命令提示符是否使用VB Script打開?
- 13. 是否有命令檢查Git Bash是否以管理員模式打開?
- 14. Windows命令行:通過文本字符串查找文件並打開它們
- 15. 無法使用SOURCE命令運行sql文件windows命令行
- 16. 打開(file).read()命令後,文本文件是否仍然打開?
- 17. 檢測錢箱是否用ESC命令打開
- 18. 批處理文件 - 檢查命令是否可用
- 19. 檢查軟件鍵盤是否在Windows Phone 8中打開?
- 20. 在閱讀文件之前檢查文件是否打開?
- 21. 是否可以使用R命令在Windows上安裝pandoc?
- 22. 在Python中打開(「文件名」,「R」)命令不起作用
- 23. 請檢查R命令
- 24. 檢查是否打開文件進行任何類型的文件
- 25. 創建R腳本文件,保存爲R腳本文件並從命令行打開R腳本文件
- 26. 在Windows上:如何正確使用上下文菜單中的「使用...打開」命令打開文件?
- 27. 如何使用指定程序從命令行打開文件?
- 28. 如何使用bat文件打開cmd並執行命令?
- 29. 使用SenTestingKit進行單元測試:檢查是否打開?
- 30. 檢查excel文件是否被其他用戶打開
切換到一個體面的PDF閱讀器不會被阻止。我使用SumatraPDF。 – Andrie 2014-09-29 15:34:07
我也使用它,但這是爲使用Adobe的其他人。 – nathaneastwood 2014-09-29 15:34:54