I want to check the number of files inside a folder and I want the result to, for example, be multiplied by 4… I tried something like:
cd path/to/my/folder && find . -maxdepth 1 -type f | wc -l | expr {} * 4
But it doesn’t work… It works until:
cd path/to/my/folder && find . -maxdepth 1 -type f | wc -l
But when I add something like "expr {} * 4"
, I get an error… I also tried other alternatives to “expr” but no luck so far.
BTW, I also want the result to be “pipeable” to another program, like ffmpeg, something like:
cd path/to/my/folder && find . -maxdepth 1 -type f | wc -l | expr {} * 4 | ffmpeg -i {} out.mp4
The above is a silly example to simplify what I’m trying to do… For those curious, I’m using https://github.com/nihui/rife-ncnn-vulkan to quadruple the frames/framerate of a video, so I need to check the number of files (images) inside a folder, automatically multiply the number by 4 and put the result in the “-n” parameter of rife-ncnn-vulkan… So a more realistic command would be something like:
ffmpeg -i "video.mkv" -r 12 -c:v libwebp -lossless 1 -y input_frames/frame_%06d.webp && cd input_frames && find . -maxdepth 1 -type f | wc -l | expr {} * 4 | rife-ncnn-vulkan -i input_frames -o output_frames -f %08d.webp -x -v -n {}
(notice the “{}” at the very end, where I want to place the result of the math operation).
Thank you in advance!