So script2 is:
find /some_directory -type f -not -iname "*.pdf" -exec bash -c './script "{}"' \; -print > temp_file
while read line
do
mkdir -p result"$(dirname "$line")"
cp "$line" ~/result"$(dirname "$line")"/$(basename "$line" .txt).pdf
done < temp_file
rm temp_file
the ./script is file "$1"|grep -q PDF
These two combined should find .txt files that are actually PDF files and then copy them to some result directory and rename them to .pdf file. But the files should be in: result/their/original/directories/file.pdf
. (if the original was some_directory/their/original/directories/file.txt
, also some directories have space in them, thus a lot of ".."
)
It is done, it works, but the question is: how to do it without mkdir?
I’ve tried many things but none seem to work and every post i read it says that it can be done just by using mkdir (but because my professor demands it to be done without mkdir, I’m quite sure it can be done. I don’t HAVE to do it, but I’d like to know how it can be done).
Maybe it can be done in find with piping? (some argument that would print directories first and they would be copied one by one and then files?) I’ve wasted a lot of time on this and it would be a shame to quit it without correct answear.