1

List of files:

$ ls -1 *.jpg
IMG_20210909_0003.jpg
IMG_20210909_0004.jpg
IMG_20210909_0005.jpg
IMG_20210909_0006.jpg
IMG_20210909_0007.jpg
…

I want to rename these files to 1.jpg, 2.jpg, …, and I know how to do it with Dired. However, this time I want to do it with Eshell.

Update, my own solution, just for fun and extremely convoluted:

$ 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 }
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.