#! /bin/sh
# testing some ideas for renaming scripts...
# remove all spaces from the filenames first
for i in *
do mv "$i" "${i// /_}"
done
# create a list of the directory contents, and turn it into a lowercase file list
ls -1 $PWD | tr "*/" " " | tr "A-Z" "a-z" > $PWD/list
# then rename all the folders in the current directory to original_name.temp
for i in $PWD/*
do mv "$i" "$i.temp"
done
# then, rename the files called original_name.temp to the lowercase name from the list file
#for i in `ls -1 | tr "*/" " "`
# do mv "$i" "$(cat list.temp)"
#done
# try to rename the files from the list.temp file using a foreach loop
#for i in *
# do foreach j=`cat list.temp`
# mv "$i" "$j"
# done
#done
# or create a new variable which contains the list of the cat'ed list.temp.
# For this, you'll need two loops
#for i in *
# for j in `cat list.temp`
# do mv "$i" "$j"
# done
#done
# multiple do's within a for...
for i in *
do NAME=`cat list.temp` && {
mv $i $NAME
}
done
Bookmarks