Reputation: 1299
I'm getting this error:
"find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]"
For this code I produced:
for subdir in `find ./$file/ -name "*.$@"`
do
new_ext=`echo $subdir | sed "s/\(.*\.\)$/\1$new/"`
mv $subfile $new_ext
done
What i'm trying to do with the code above is rename files extensions in current and sub-directories without having to enter the old file extension.
Any help pointing out what i'm doing wrong would be grateful.
Upvotes: 2
Views: 3490
Reputation: 40688
Here is my attempt:
for old_extension in "$@"
do
find ./$file -name "*.$old_extension" | while read old_file
do
new_file=${old_file%$old_extension}new
echo mv "$old_file" "$new_file"
done
done
Upvotes: 2
Reputation: 798526
"*.$@"
surely doesn't do what you want. Build the command in an array.
Upvotes: 1