diff options
author | JJ <nicetry@noemail.com> | 2025-03-19 14:56:26 +0000 |
---|---|---|
committer | JJ <nicetry@noemail.com> | 2025-03-19 14:56:26 +0000 |
commit | 16f52b7bef745097f7076dde76715db378b54343 (patch) | |
tree | cfcacda8adced2059dcc120d2bc2446d3c4f960a /content/snippets/loop-files-rename.md |
first commit
Diffstat (limited to 'content/snippets/loop-files-rename.md')
-rw-r--r-- | content/snippets/loop-files-rename.md | 13 |
1 files changed, 13 insertions, 0 deletions
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 |