내에서 열려 있는지 확인하십시오. shell()
명령을 사용하여 함수 내에서 .tex 파일로부터 pdf 문서를 생성하고 있습니다. 이 함수는 때때로 조정 된 데이터로 여러 번 실행되기 때문에 문서를 덮어 씁니다. 물론 .tex 파일을 실행할 때 pdf 파일이 열려 있으면 .tex 파일을 실행할 수 없다는 오류가 발생합니다. 따라서 파일이 열려 있는지 여부를 확인하는 R 또는 Windows cmd 명령이 있는지 알고 싶습니다.파일이 Windows 명령 행에서 R
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.
.
--
차단하지 않는 괜찮은 PDF 판독기로 전환하십시오. 나는 수마트라를 사용한다. – Andrie
나는 이것을 사용하지만 이것은 Adobe를 사용하는 다른 사람을위한 것입니다. – nathaneastwood