我正在使用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