|Don't ask to ask, just ask|
The most pertinent issues are:
(1) at the least under unix, you could get an error trying to rename . and .. (the current and parent directories). To avoid that, replace the readdir with
(2) but, just in case there are yet more files in the directory that you don't want to rename, you might consider instead:
(3) the '.' operator in the arguments to rename will not produce a literal '.' as has already been hinted at.
(4) it is possible but suspicious that you expect to have a mount point at '/temp_gif' ... should this not be './temp_gif'?
(5) if so, then when that is corrected, the fix suggested by others of putting the relative or full path in front of the arguments to rename will become able to function.
One world, one people