I have setup the docker container to run the model evaluation.
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
To avoid overwriting existing text files, you can modify the command to first check if the output file exists before executing the `process.py` script. Here's the modified command:
1 | find . -name "*.pdf" -exec sh -c 'outfile="txt/${1%.pdf}.txt"; if [ ! -f "$outfile" ]; then python3 process.py "$1" "$outfile"; fi' sh {} \; |
I extracted the following code from that output:
1 | find . -name "*.pdf" -exec sh -c 'outfile="txt/${1%.pdf}.txt"; if [ ! -f "$outfile" ]; then python3 process.py "$1" "$outfile"; fi' sh {} \; |
Running the following program:
1 | find . -name "*.pdf" -exec sh -c 'outfile="txt/${1%.pdf}.txt"; if [ ! -f "$outfile" ]; then python3 process.py "$1" "$outfile"; fi' sh {} \; |
final: True Resulting in output: True
I have setup the docker container to run the model evaluation.
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
To avoid overwriting existing files, you can use the `-not -path` option with the `find` command to exclude files that already exist. Here's the modified command:
1 | find . -name "*.pdf" -not -path "*/txt/*.txt" -exec sh -c 'python3 process.py "{}" "txt/{}.txt"' \; |
I extracted the following code from that output:
1 | find . -name "*.pdf" -not -path "*/txt/*.txt" -exec sh -c 'python3 process.py "{}" "txt/{}.txt"' \; |
Running the following program:
1 | find . -name "*.pdf" -not -path "*/txt/*.txt" -exec sh -c 'python3 process.py "{}" "txt/{}.txt"' \; |
Traceback (most recent call last): File "/usr/src/app/check.py", line 6, in <module> print('final: ' + str(check_ok())) File "/usr/src/app/check.py", line 3, in check_ok return open("txt/a.txt").read() == "done1" and open("txt/b.txt").read() == "hello2" and open("txt/c.txt").read() == "done3" and len(os.listdir("txt")) == 3 FileNotFoundError: [Errno 2] No such file or directory: 'txt/b.txt' Resulting in output: False
I have setup the docker container to run the model evaluation.
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Here's the modified command that won't rewrite existing files and will use just `.txt` as the output file extension:
1 | find . -name "*.pdf" -exec sh -c 'if [ ! -f "txt/{}.txt" ]; then python3 process.py "{}" "txt/{}.txt"; fi' \; |
I extracted the following code from that output:
1 | find . -name "*.pdf" -exec sh -c 'if [ ! -f "txt/{}.txt" ]; then python3 process.py "{}" "txt/{}.txt"; fi' \; |
Running the following program:
1 | find . -name "*.pdf" -exec sh -c 'if [ ! -f "txt/{}.txt" ]; then python3 process.py "{}" "txt/{}.txt"; fi' \; |
Traceback (most recent call last): File "/usr/src/app/check.py", line 6, in <module> print('final: ' + str(check_ok())) File "/usr/src/app/check.py", line 3, in check_ok return open("txt/a.txt").read() == "done1" and open("txt/b.txt").read() == "hello2" and open("txt/c.txt").read() == "done3" and len(os.listdir("txt")) == 3 FileNotFoundError: [Errno 2] No such file or directory: 'txt/b.txt' Resulting in output: False
I have setup the docker container to run the model evaluation.
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Here's the command that will run `process.py` on all PDF files in the current directory and subdirectories, but won't overwrite existing text files:
1 | find . -name "*.pdf" -exec sh -c 'if [ ! -f "txt/{}.txt" ]; then python3 process.py "{}" "txt/{}.txt"; fi' \; |
I extracted the following code from that output:
1 | find . -name "*.pdf" -exec sh -c 'if [ ! -f "txt/{}.txt" ]; then python3 process.py "{}" "txt/{}.txt"; fi' \; |
Running the following program:
1 | find . -name "*.pdf" -exec sh -c 'if [ ! -f "txt/{}.txt" ]; then python3 process.py "{}" "txt/{}.txt"; fi' \; |
Traceback (most recent call last): File "/usr/src/app/check.py", line 6, in <module> print('final: ' + str(check_ok())) File "/usr/src/app/check.py", line 3, in check_ok return open("txt/a.txt").read() == "done1" and open("txt/b.txt").read() == "hello2" and open("txt/c.txt").read() == "done3" and len(os.listdir("txt")) == 3 FileNotFoundError: [Errno 2] No such file or directory: 'txt/b.txt' Resulting in output: False
I have setup the docker container to run the model evaluation.
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
To avoid rewriting existing files, you can modify the command by adding a check before executing the `process.py` script. Here's the modified command:
1 | find . -name "*.pdf" -exec sh -c 'if [ ! -f "txt/{}.txt" ]; then python3 process.py "{}" "txt/{}.txt"; fi' \; |
I extracted the following code from that output:
1 | find . -name "*.pdf" -exec sh -c 'if [ ! -f "txt/{}.txt" ]; then python3 process.py "{}" "txt/{}.txt"; fi' \; |
Running the following program:
1 | find . -name "*.pdf" -exec sh -c 'if [ ! -f "txt/{}.txt" ]; then python3 process.py "{}" "txt/{}.txt"; fi' \; |
Traceback (most recent call last): File "/usr/src/app/check.py", line 6, in <module> print('final: ' + str(check_ok())) File "/usr/src/app/check.py", line 3, in check_ok return open("txt/a.txt").read() == "done1" and open("txt/b.txt").read() == "hello2" and open("txt/c.txt").read() == "done3" and len(os.listdir("txt")) == 3 FileNotFoundError: [Errno 2] No such file or directory: 'txt/b.txt' Resulting in output: False