directory and files chmod

So i have about 600gb of data.. in which there are alot of directories and alot of files.. Im trying to put this on a ftp server.. So i want to set the permissions on the directories to be 755 and the permission on the files to be 644. So i used:

Code:
find . -type d -exec chmod 755 {}\;
and
Code:
find . -type f -exec chmod 644 {}\;

The command for the files seemed to work on the majority of the files.. But the one for directories worked for like 30% of my diretories.. Can you guys recommend another way of doing this.. To make sure "all" my files are set to 644 and "all" my directories are set to 755... Also the folders that are not getting change have a 777 permission. Also im running this command from the main directory
 
Make sure the owner and group are set correctly for those directories. You cannot change permissions on files/directories you do not own.

Only the owner of a file or the super-user is permitted to change the mode of a file.
See chmod(1).

If you want to change ownership of a complete directory tree use chown with the -R switch.
 
Ran this script and it fixed:

Code:
find . -type d -print | while read DIR
do
         chmod 755 "${DIR}"
done

find . -type f -print | while read FILENAME
do
         chmod 644 "${FILENAME}"
done
 
Which does exactly the same as the first commands you've posted.
 
For anyone duping in to this rather old thread.
The script suggested by SubperMiguel must be in the base directory form where one wants to change the permissions.
From the command line use:
Code:
find /path/to/base/dir -type d -exec chmod 755 {} +

find /path/to/base/dir -type f -exec chmod 644 {} +
 
Back
Top