2

I have a very specific and odd problem to solve. I'm working as a research assistant and I've been producing a ton of figures. In one directory, I dump .pngs to view casually (limited space here) and in the another, I dump .ps and .pdf files to use in latex. It's all automated with matlab. In the .png folder, I've periodically deleted many files I deemed not useful, but the other one is a mess.

How can I tell unix to go through the .ps directory, and for each file, search the .png directory for filenames that match, and then, if they don't match, move the file to a different directory (that I will most likely later delete)?

Are there any commands that could be useful here?

1 Answer 1

3

A crude way to do it:

for f in /path/to/PDFs/*.pdf; do
    base=$( basename "$f" .pdf )
    if [ ! -f /path/to/PNGs/"$base".png ]; then
        mv "$f" /path/to/garbage/
    fi  
done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .