help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to rename files to numbers in Eshell?


From: Felix E. Klee
Subject: Re: How to rename files to numbers in Eshell?
Date: Thu, 16 Sep 2021 14:15:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

"Felix E. Klee" <felix.klee@inka.de> writes:
>     $ listify *.jpg
>     $ setq my-files $$
>     $ setq my-numbers $(number-sequence 1 (length my-files))
>     $ setq my-pairs $(mapcar* 'cons my-files my-numbers)
>     $ for pair in $my-pairs { setq a (car pair); setq b (cdr pair);
>       mv $a "$b".jpg }

I just learned about [Eshell backticks][1].  So the first two lines can
be merged, even improving readability IMHO:

    $ setq my-files ${listify *.jpg}
    $ setq my-numbers $(number-sequence 1 (length my-files))
    $ setq my-pairs $(mapcar* 'cons my-files my-numbers)
    $ for pair in $my-pairs { setq a (car pair); setq b (cdr pair);
      mv $a "$b".jpg }

Now the question remains if there is a more terse way to do the rest of
the steps.

[1]: https://www.emacswiki.org/emacs/Eshell




reply via email to

[Prev in Thread] Current Thread [Next in Thread]