0

Question is : Write a Bash shell script that will rename all the files in a directory. It will mostly be useful to rename digital picture files. The first argument is a base name, second argument is a file extension. If it is run as:

$ rename vacation jpg then the resulting files should have names like: vacation001.jpg, vacation002.jpg, vacation003.jpg, etc.

I tried until here but I couldn't continue. Can you help me?

#!usr/bin/bash
a=1
directory=$1
for i in directory ; do
  • how does this relate to ask ubuntu? – graham May 21 '21 at 16:01
  • 4
    There are already several (well answered) questions about [Sequential renaming of files](https://askubuntu.com/questions/679283/sequential-renaming-of-files) and how to [Rename multiple files sequentially and starting by the same prefix](https://askubuntu.com/questions/1108141/rename-multiple-files-sequentially-and-starting-by-the-same-prefix) – steeldriver May 21 '21 at 16:12
  • @24601 If bash is run on Ubuntu, the question is on-topic https://askubuntu.com/help/on-topic, though indeed answered before – Bruni May 21 '21 at 17:01
  • 1
    @Bruni well that was what I asked. – graham May 21 '21 at 18:29

0 Answers0