Using makefile wildcard command for file names with spaces

前端 未结 1 1179
孤街浪徒
孤街浪徒 2021-01-01 19:53

I have a makefile that I use to compress pictures:

src=$(wildcard Photos/*.jpg) $(wildcard Photos/*.JPG)
out=$(subst Photos,Compressed,$(src))

all : $(out)
         


        
相关标签:
1条回答
  • 2021-01-01 20:34

    Generally having spaces in file names is a bad idea with make, but for your case this may work:

    src=$(shell find Photos/ -iname '*.JPG' | sed 's/ /\\ /g')
    
    out=$(subst Photos,Compressed,$(src))
    
    all : $(out)
    
    Compressed:
      @mkdir Compressed
    
    Compressed/%: Photos/% Compressed
      @echo "Compressing $<"
      @convert "$<" -scale 20% "$@"
    
    0 讨论(0)
提交回复
热议问题