그래서 .. 저는 * .doc 파일을 * .pdf로 변환하는 작업을했습니다. lowriter
내가하고 싶은 것은이 작업을 제자리에서하는 것이지만을 사용하여 수행 할 수있는 옵션이 없기 때문에 lowriter
원래 파일과 경로를 캡처하고 변환을 캡처 한 다음 변환 된 파일을 원래 경로로 이동해야한다고 생각했습니다. 그런 다음 원본 * .doc를 삭제하십시오.
문제는 내 sed
이고 awk
기껏해야 약하다.) 그래서 출력에서 변환 된 파일 이름을 "캡처"할 수있는 방법을 알 수 없습니다.
내 코드 :
#! / bin / bash
FILES=/my/path/**/*.doc
shopt -s globstar
for f in $FILES; do
the_file=$f;
the_orig_dir=$(dirname "$the_file") ;
converted=$(lowriter --headless --convert-to pdf "$the_file");
echo $converted;
done;
출력은 다음과 같습니다.
convert /my/path/Archives/Ally/Heavenly Shop.doc -> /my/Heavenly Shop.pdf using filter : writer_pdf_Export
convert /my/path/Archives/Ally2/Solutions Shop.doc -> /my/Solutions Shop.pdf using filter : writer_pdf_Export
convert /my/path/Archives/Ally3/Xpress Shop.doc -> /my/Xpress Shop.pdf using filter : writer_pdf_Export
내가해야 할 것은 후 변환 된 파일의 경로 / 파일 이름을 캡처입니다 ->
그리고 전에 :
. 어떻게 할 수 있을지 모르겠어요. 누군가 말해 줄 수 있습니까?
#!/bin/bash
FILES=/my/specific/input/folder/**/*.doc
shopt -s globstar
for f in $FILES; do
the_file=$f;
the_orig_dir=$(dirname "$the_file") ;
converted=$(lowriter --headless --convert-to pdf "$the_file");
new_file=$(echo "$converted" | grep -o -P '(?<= -> ).*(?= using filter : )');
new_file_name=$(basename "$new_file");
echo "$the_orig_dir/$new_file_name";
set -x;
rm -f $the_file;
mv "$new_file" "$the_orig_dir/";
set +x;
done;
내가해야 할 일을 해
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다