in reply to Renaming Files

... it keeps giving me an error message "No such file or directory" At least it is trying to rename the files. Do you have any ideas?

When you open and read a directory, the names that you get don't have leading path components. Unless you're chdir()'d to the directory, you'll need to prepend the path before doing operations like -d, -e, or rename().

In your case, that means prepending $line or $newdir.