Categories
Apple User Help

How to change multiple text file names? [closed]

soilbase.0.out.satur.00001.pfb
soilbase.0.out.satur.00002.pfb
soilbase.0.out.satur.00003.pfb
soilbase.0.out.satur.00004.pfb
soilbase.0.out.satur.00005.pfb

I have files like these and I need to rename like as below,

soilbase.1512.out.satur.01513.pfb
soilbase.1512.out.satur.01514.pfb
soilbase.1512.out.satur.01515.pfb
soilbase.1512.out.satur.01516.pfb
soilbase.1512.out.satur.01517.pfb

I wrote a code to rename, it run but outcome is not exactly what I want.
my script is as below
function rename() { echo "———————————————— STARTED ————————————————" # Counter. COUNTER=1 # For do loop. for file in *."$1"; do mv "$file" "$1514-$COUNTER.$1" COUNTER=$[$COUNTER +1] done echo "———————————————— ✔✔✔ RENAMED Every $1 file in the PWD! ✔✔✔︎ ————————————————" } rename pfb soilbase.1512.out.satur.

I have to run it in matlab or bash script, if anyone can, please help. Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *