I am trying to convert a bunch of jpeg files to a pdf file.When I type the filenames with the quotes all is fine:$ img2pdf ./Page 001.jpg ./Page 002.jpg -o book.pdfWhen I go for the wildcards, I get an error from img2pdf suggesting it got ./Page instead of ./Page 001.jpg: IOError: [Errno 22] invalid mode ('rb') or filename: './Page'Here is the command I use:$ img2pdf `find . -name Page*.jpg -printf \%p\ ` -o book.pdfWhat might go wrong? Thanks for your help
Having trouble with img2pdf and spaces in filenames
shell;find;quoting;wildcards;command substitution
I suppose you are in bash, so ... bash will interpret some character as separators. it depends by content of $IFS (internal field separator) environment variable which have his default value to whitespace (space, tab and newline). So when it will find a space character inside your file name it will be interpreted as a separator and will split file name in one or more pieces (it depends on how many spaces, tabs or new lines will found).Solution could be to change $IFS value to something that match your needs.for example in you case only new line characters should be interpreted as a separator:# first save current valueOLD_IFS=$IFS# change value to something you needIFS=\n# do what you need to do here############################## restore default value of IFSIFS=$OLD_IFSfor more details see this documentationIFS referenceEDIT:I just made some tests with img2pdf. I have 101 images named like name_0.png, name_1.png, name_2.png, ..., name_100.pngto put them in a test.pdf file I used this commandimg2pdf -o test.pdf name_{0..100}.pngand there was no problems with this.Then I made another test with files with spaces in names like:name 0.png, name 1.png, name 2.png, ..., name 100.pngand command is (space character is escaped by backslash):img2pdf -o test.pdf name\ {0..100}.pngI hope this will help you.