How can i rename list of files in a directory?
By using the mv command.
My answer was as useful to you as your question was to me. My statement is completely correct but does not have enough information to be useful to you.
In order for us to answer so that you can benefit from it please provide us:
-- what new name(s) do you want?
-- please us an example input and your expected output.
sorry
scenario
for ex in a directory i have 3 files with names as
oldfile111.txt
oldfile222.txt
oldfile333.txt
i want this to be renames to
newfile111.txt
newfile222.txt
newfile333.txt
Thanks in advance...
while read fname
do
newname=$(echo "$fname" | sed 's/oldfile/newfile/')
mv $fname $newname
done < list_of_files.txt
Alternatively try:
oldname=oldfile newname=newfile
for file in "${oldname}"*; do
mv "$file" "${newname}${file#$oldname}"
done