Jump to content

deleting files and folders in user areas via script


Recommended Posts

Posted

Hi

 

As its coming towards the end of the year I am looking at a solution to delete all of year 7,8, and 9 data which is stored in their home directories on the Mac server.

 

All of our users have open directory accounts and rather me delete everyones account and recreate them again is there a way I can run a script or application on our Mac server for it to interregate a selection of home folders and delete all the contents in there so in September all students come back using their existing credentials and they have empty home directories?

 

Our storage is getting rather full and don't have the funds to buy additional storage so need to do something to clear it out a bit.

 

Thanks

Posted

I just found this command on the Apple website which may do the trick called 'createhomedir'. Has anyone used this command to bulk create user home directories. Mac OS X Server: How to Use createhomedir Command to Create Home Directories

 

I am thinking if I can delete a selection of home folders (mainly for the lower year groups) then run this command on the directory I want it to create the folders in, hopefully happy days!!

Posted

Hi Ranj

 

You actually don't need to use the command line if you don't want to as what you're asking for can be easily achieved using the interface. If you want to clear space yet still keep the same User Base then simply delete (or backup if you still need them?) home folders you're not interested in any more. Launch WorkGroup Manager and authenticate to the LDAP node. Select all the Users - apart from Directory Administrator - click on the Home Tab. Select the appropriate url. Click Create Home Folder now and click Save. Navigate to the relevant folder in the Finder and watch it populate with fresh, new home folders which should have User shortnames as the name of the folder. Each folder should have the default set of folders normally associated with a mac home folder. No need to fiddle with permissions either as these will be 'set' at their defaults as the folders are created.

 

If you want to use Terminal, issuing this command:

 

sudo createhomedir -a

 

does the same thing only quicker.

 

Antonio Rocco (ACSA)

  • Thanks 1
Posted
Hi Ranj

 

You actually don't need to use the command line if you don't want to as what you're asking for can be easily achieved using the interface. If you want to clear space yet still keep the same User Base then simply delete (or backup if you still need them?) home folders you're not interested in any more. Launch WorkGroup Manager and authenticate to the LDAP node. Select all the Users - apart from Directory Administrator - click on the Home Tab. Select the appropriate url. Click Create Home Folder now and click Save. Navigate to the relevant folder in the Finder and watch it populate with fresh, new home folders which should have User shortnames as the name of the folder. Each folder should have the default set of folders normally associated with a mac home folder. No need to fiddle with permissions either as these will be 'set' at their defaults as the folders are created.

 

If you want to use Terminal, issuing this command:

 

sudo createhomedir -a

 

does the same thing only quicker.

 

Antonio Rocco (ACSA)

 

Thank you Tony for your reply I confirm this works and this will help a great deal. I am looking at another way (if possible) to recover more disk space. I was looking at if there is a way to again look at everyones home directory and delete the contents of the trash folder.

 

Do you or does anyone know of a way to do this? Could this be done in Automator?

 

Thanks

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...