Batch Rename Folders

Problem:I’ve been trying to rename 1000+ folders to template_XXXX where the XXXX is a number. I want to rename all the folders, but don’t want the subfolders to be changed, only the parents.

Solution:

num=1; 
for dir in `find -maxdepth 1 -type d` ; 
  do mv $dir template_$num ; 
  num=$((num + 1)) ; 
done

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.