how to use find with space charracters?

Post here if you are a new Porteus member and you're looking for some help.
benjibasson
Samurai
Samurai
Posts: 141
Joined: 06 Mar 2019, 15:14
Distribution: Arch linux

how to use find with space charracters?

Post#1 by benjibasson » 28 Mar 2024, 12:35

Hi
I would like to stamp sur la first page on every PDF in a folder ( 200 files with spaces)
I have created my stamp on wight A4 PDF with gimp
then do an single succesfull try

Code: Select all

qpdf ./a.pdf --underlay sign.pdf -- ./c.pdf 
I try to launch the script to repeat for every PDF

Code: Select all

find ./ -name '*.pdf' -execdir bash -c 'qpdf $0 --underlay /home/guest/sign.pdf -- ${0/.pdf/-signe.pdf}' {} \;
unfortunaly it fails because find ./ -name don't work with space caracter

Code: Select all

find ./ -name '*.pdf' -execdir bash -c 'qpdf $0 --underlay /home/guest/sign.pdf -- ${0/.pdf/-signe.pdf}' {} \;

qpdf: unknown argument the

Usage: qpdf [options] {infile | --empty} [page_selection_options] outfile
For detailed help, run qpdf --help


qpdf: unknown argument little

Usage: qpdf [options] {infile | --empty} [page_selection_options] outfile
For detailed help, run qpdf --help


qpdf: unknown argument house

...
If I do

Code: Select all

find ./ -name '*.pdf' -execdir bash -c 'qpdf $0 --underlay /home/guest/sign.pdf -- ${0/.pdf/-signe.pdf}' _ {} \;
I got

Code: Select all

open _: No such file or directory
open _: No such file or directory
open _: No such file or directory
open _: No such file or directory
open _: No such file or directory
open _: No such file or directory
open _: No such file or directory
open _: No such file or directory
open _: No such file or directory
open _: No such file or directory
open _: No such file or directory
open _: No such file or directory
open _: No such file or directory
open _: No such file or directory
When I do

Code: Select all

find ./ -name '*.pdf' -execdir bash -c 'echo $0' {} \;

I get the accurate list

Code: Select all

find ./ -name '*.pdf' -execdir bash -c 'echo $0' {} \;
./01042023 RAPPORT 1.pdf
./01042023 Rapport 2.pdf
./01042023 rapport 3.pdf

...
What is the syntax for find for space charracters please

Cheers

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3941
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

how to use find with space charracters?

Post#2 by ncmprhnsbl » 29 Mar 2024, 01:07

looks like to me that find is ok with the spaces but qpdf isn't.
maybe try double quoting find's output:

Code: Select all

find ./ -name '*.pdf' -execdir bash -c 'qpdf "$0" --underlay /home/guest/sign.pdf -- "${0/.pdf/-signe.pdf}"' _ {} \;
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

how to use find with space charracters?

Post#3 by Ed_P » 29 Mar 2024, 02:47

I have found a ? works for files in My?Files folder.
Ed

Vic
Samurai
Samurai
Posts: 122
Joined: 10 Aug 2016, 05:36
Distribution: Porteux V-0.1 64 KDE
Location: Utopia in Tampa, Florida, USA

how to use find with space charracters?

Post#4 by Vic » 29 Mar 2024, 08:52

I hate spaces and anything that is not a . <period> or - <hyphen> or _ <underscore> . I remove the stuff whenever possible.

I found this post on CommandLineFu website and it works for me. No clue how, though.

https://www.commandlinefu.com/commands/ ... ctory-tree.

and this too ...

https://www.commandlinefu.com/commands/ ... nderscores

Maybe they will make things easier but use at your own risk.

Vic

Post Reply