You are not logged in.

#1 2023-03-30 14:34:03

Sergeif
Member
Registered: 2018-09-24
Posts: 12

[SOLVED] Move files baased on content

Hi everybody,

I can't fond a solution to my issue. Hopefully you could help me.
I have a few thousands of pdf files that I need to sort and move to different directoried based on the keyword in the content.
I use pdfgrep to list the files and trying to use xargs to move them.
Example:

pdfgrep -Hir 'text' | xargs -I'{}' mv '{}' 'Destination Directory'

It looks like xargs is trying to move the file based on the keyword (and obviously can't find the file).
How do I tell xargs to use the filename from the pdfgrep output?

Last edited by Sergeif (2023-03-30 16:18:41)

Offline

#2 2023-03-30 14:58:27

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,553
Website

Re: [SOLVED] Move files baased on content

Look at the output of that pdfgrep command (before piping it) and it should be obvious.

Then read the pdfgrep man page for the -l flag.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2023-03-30 14:58:50

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,930

Re: [SOLVED] Move files baased on content

https://man.archlinux.org/man/community … fgrep.1.en
There's an option that does exactly what you want and it's not "-H"

Offline

#4 2023-03-30 16:08:01

Sergeif
Member
Registered: 2018-09-24
Posts: 12

Re: [SOLVED] Move files baased on content

Trilby wrote:

Look at the output of that pdfgrep command (before piping it) and it should be obvious.

Then read the pdfgrep man page for the -l flag.

seth wrote:

https://man.archlinux.org/man/community … fgrep.1.en
There's an option that does exactly what you want and it's not "-H"


Thanks a lot. It's working.

Offline

Board footer

Powered by FluxBB