I have several files to copy from various directories but each file has the same name so I need to copy them to a single directory and rename each in turn as expect1, expect2, expect3, etc.The code I've tried so far is     let i=1; for file in delay* ; do (     cd $file     cp expectation_file ~/target_dir     cd ~/target_dir/     mv expectation_file expect{i}     ((i++)) );     doneBut this just makes every file called expect1. Can someone help out? I think it's the counting loop that's wrong but can't figure it out. Thanks!EDIT: Made a mistake in code there. Had 1=1 instead of i=1 and then ++i not i++.
Copy multiple files from different directories while renaming?
rename;for
This may be more versatile.#!/bin/bashi=0source_files=$(find /tmp -name *.zip)target_dir=~/temp1/for source in ${source_files}; do  ((i++))  mv ${source} ${target_dir}/$(basename ${source})${i}donesource_files expression can be anything like $(ls *.zip), this example finds all zip files under /tmp/.