aboutsummaryrefslogtreecommitdiff
path: root/content/snippets/loop-files-rename.md
blob: 27a3134f6a611b15ea603c2a03cae2184745266c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
---
title: Batch rename files using file index
description: Batch rename files using file index
tags: ["commandline"]
---

This terminal command renames all .jpg files in a directory to `{name}{index}.jpg`:

```console
i=1; for f in *.jpg; do mv -- "$f" "name-$i.jpg"; i=$((i+1)); done
```

`name` is just a placeholder, replace with whatever