From 16f52b7bef745097f7076dde76715db378b54343 Mon Sep 17 00:00:00 2001 From: JJ Date: Wed, 19 Mar 2025 14:56:26 +0000 Subject: first commit --- content/snippets/loop-files-rename.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 content/snippets/loop-files-rename.md (limited to 'content/snippets/loop-files-rename.md') diff --git a/content/snippets/loop-files-rename.md b/content/snippets/loop-files-rename.md new file mode 100644 index 0000000..27a3134 --- /dev/null +++ b/content/snippets/loop-files-rename.md @@ -0,0 +1,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 -- cgit v1.2.3