Let's say I'd like to know how many .png images I have in a folder. In shell I'd run:
ls -1 | grep .png | wc -l
Is there a way to achieve this in emacs (preferably not just reading in from a shell output)?
Let's say I'd like to know how many .png images I have in a folder. In shell I'd run:
ls -1 | grep .png | wc -l
Is there a way to achieve this in emacs (preferably not just reading in from a shell output)?
(length (directory-files "~/Pictures" nil "\\.png\\'"))
See C-hf directory-files
.png and .jpeg, how would the regex look like? I tried [(.png)|(.jpeg)], but it matches other things too.
"\\.\\(png\\|jpeg\\)\\'" will do the trick in Emacs.
rx regexp compiler like so: (rx "." (or "png" "jpeg") string-end)
In dired (in directory in which you want to count .png files)
run M-x eshell-command:
(length (directory-files "" nil "\\.png\\'"))