Need a script to delete files

Hi
Can someone advise me on how to create a script to delete certain files from a users home account at logout?
The files that I want deleting are .plist files in there ~/lib.../preferences folder, this is so I can ensure that all users will have the same settings for certain files next time they login again.
Thanks

That being said, if you you still really want to do this you can create a logout hook and write a shell script to remove the files.  See "About Daemons and Services", Appendix B on writing a logout hook.
But a far easier way is to create Account's login item that will cause a shell script to be launched to delete the files.  You can encapsulate the shell script so it runs as an application that can be added to the Login Items.  One such encapsulator is Platypus.
Note, rather than delete them, if you want to ensure all the specific plists have specific settings, then create a master set of them and copy the master set into the Preferences directory (being careful to observe ownership and permissions settings of course).

Similar Messages

  • Script to delete files created on a specific date with sepecific name

    Hi,
    Is it possible to help me with a powershell script that delete files under a folder and subfolders that have the following attributes
    1. have the name (default.*) and (index.*)
    2. created on a specific date say 1-9-2014
    3. created between specific time say between 10:00 - 16:00
    Thanks in advance!

    break out the components of the script.
    IE does this match 
    Get-ChildItem -Recurse c:\temp\*.*or Get-ChildItem -Recurse c:\temp\*.* | Where-Object {$_.CreationTime -gt (get-date "01-09-2014 10:00AM") -and $_.
    CreationTime -lt (get-date "01-09-2014 14:00PM")}Get-ChildItem -Recurse c:\temp\*.* | Where-Object {$_.CreationTime -gt (get-date "01-09-2014 10:00AM") -and $_.
    CreationTime -lt (get-date "01-09-2014 14:00PM")} | Where-Object {$_.name -match "default"}Might not be working as it might not be matching.Once you get it matching the remove-item will work.
    Cheers,
    Martin
    Blog:
    http://sustaslog.wordpress.com 
    LinkedIn:
    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

  • PowerShell: Script to delete files older than X days

    Hi All,
    I am testing a script to delete files and I have it written down in my notepad as below:
    $foldername = $args[0]
    $maxage =      $args[1]
    gci $foldername | Where-object {($_-is [io.fileinfo]) -and ($_.lastwritetime -lt (get-date).AddDays(-$maxage) ) } |
    remove-item -whatif
    Question: When i try to run the script and  pass the parameters $foldername and 30 it doesn't return anything. I am expecting it to return with -Whatif
    To execute the script I wrote:
    .\myscipts\del.ps1  cmd2 30
    cmd2 is the name of the folder in my drive and 30 is ($maxage)  number of days old.
    Thank-you
    SQL 75

    Thansks jrv, looks good! One more thing I wanted to ask do you know what it means by the error:
    "An Empty Pipe Element is not Allowed" I altered my script a bit but it gives me this error. and I am passing no parameters when i call the script. My Script I created is below:
    $name = $args[0]
    $chew = $args[1]
    IF ( $args.count -lt 2)  { Write-host "Please provide 2 parameters for this to work"
                    exit 1 }
    GCI $name | Where-object { $_-is [io.fileinfo]  -and ($_.lastwritetime -lt (get-date).AddDays(-$chew))}
     | remove-item -whatif
    Thank-you
    SQL 75

  • Need a script to delete Old domain profiles folders

    Hi
    Thanks in Advance
    I have desk space issue in my Org.
    There are 3000 to 5000 windows servers exist in our Org.
    I am running a desk clean every day with a script
    1)      C:\Temp; C:\WINDOWS\Downloaded Installations; C:\WINDOWS\Offline
    Web Pages; C:\WINDOWS\servicepackfiles; C:\WINDOWS\temp
    2)      It runs the below commands on all the above folders
    DEL /F /Q /S C:\temp\*
    for /D %%i in ("C:\temp\*") do RD /S /Q "%%i"
    But I am still facing issue with C drive space, as many domain accounts  users login into the servers and folder are created in
    Windows 2003: c:\Document settings\<user folder>
    windows 2008: C:\users\<user folder> 
    So i need manullay login into the servers to delete this user profiles folder.
    I need a script to clear this folders older than 30 days.
    Please help me
    Thanks
    Rajesh

    In WIndows 2003 use delprof to remve old profiles
    DELPROF:
    http://www.microsoft.com/en-us/download/details.aspx?id=5405
    DELPROF /c:\\computername /d:30
    On WS2008 and later use Group Policy.
    On Termminal Server profiles should be roamed to a NAS or SAN or file server and the session should be set to remove the local copy at the end of the session.
    On Windows 2008 you can fairly easily move the users folder "C:\Users" to another drive if youare running out of space.  Terminal Server only porfiles can be moved seeparately to a new drive or network location using RDS configuration or Group
    Policy.
    ¯\_(ツ)_/¯

  • Need a script to move files to folders

    Hi guys.  I have found a lot of similar threads but not something exactly like what I need.
    I have a ton of files that need to be sorted into folders of the same name.  I found scripts to help me with that however, I have some variations on the files with an extension to the file name that also need to be moved into the same folders.
    For instance, I have a folder named....
    spiegal_case_25_video_3
    and I have the following files that all need to be moved into that folder....
    spiegal_case_25_video_3.mp4
    spiegal_case_25_video_3.webmsd.webm
    spiegal_case_25_video_3_h.flv
    spiegal_case_25_video_3_m.flv
    spiegal_case_25_video_3_l.flv
    I have found scripts to get me part of the way there but I can't get the FLVs into the folders because of the _h _m and _l extensions on the file names.  Is there a way to move these files into their appropriate folders (maybe by ignoring the last 2 characters in the file name?)
    I have also found a script that will read everything up to the underscore, but that won't help since the file names have multiple underscores.  So I really need a script that can do the sorting while ignoring the last 2 characters in the file name.
    Can anyone help me out?  I'm not very script savvy.
    Thanks!

    I've tested the following script (under OS X 10.8.5) with 4 subfolders and 20 files, all located in a folder called "Master folder" located in a USB flash drive named "EXT_DRIVE". It seems to work flawlessly. In its present state, the script will replace any file already located in any of the subfolders.
    set theMasterFolder to POSIX file "/Volumes/EXT_DRIVE/Master folder"
    tell application "Finder"
        activate
        set theFolders to (folders of folder theMasterFolder) as alias list
        repeat with thisFolder in theFolders
            set thisName to name of thisFolder
            move (files of folder theMasterFolder whose name begins with thisName) to thisFolder with replacing
        end repeat
    end tell

  • Need more disk memory--Deleting files

    I am trying to delete and back up documents, pictures, etc. because I only have 3 Gigs of space, not enought memory to upgrade to the new operating system. I am still running on Leopard (sigh) I found a folder named, "scanner output" with all the photos I have scanned onto my computer and have either emailed to friends and family or uploaded to iphoto.  Am I ok to delete these files to open up memory space? Will it delete any of the photos I have in iphoto?

    If the scanner output is a separate folder, this will not do anything to your iPhoto Library.
    Before arbitrarily deleting items, you have the option of either burning your data to discs, Flash drives or purchasing an external hard drive and copying or cloning your important data there.
    I would save the data rather than deleting it. You never know when you might have a need to recover old data files.
    Here are some of my tips for deleting or archiving data off of your internal hard drive.
    You'll need to free up lots of hard drive space.
    At a minimum, at least, 15 to 20 GBs of space.
    Perhaps even more.
    Hard drive full or near full:
    Have you emptied your iMac's Trash icon in the Dock?
    If you use iPhoto, iPhoto has its own trash that needs to be emptied, also.
    If you use Apple Mail app, Apple Mail also has its own trash area that needs to be emptied, too!
    Other things you can do to gain space.
    Delete any old or no longer needed emails and/or archive older emails you want to save.
    Look through your Documents folder and delete any type of old useless type files like "Read Me" type files.
    Again, archive or delete any old documents you no longer use or immediately need.
    Uninstall apps that you no longer use. If the app has a dedicated uninstaller, use it to completely uninstall the app. If the app has no uninstaller, then just drag it to the OS X Trash icon  and empty the Trash.
    Also, if you save old downloaded  .dmg application installer  files, you can either archive and delete these or just delete the ones you think you'll never install, again.
    Download an app called OnyX for your version of OS X.
    When you install and launch it, let it do its thing initially, then go to the cleaning and maintenance tabs and run all of the processes in the tabs. Let OnyX clean out all web browser cache files, web browser histories, system cache files, delete old error log files.
    Typically, iTunes and iPhoto libraries are the biggest users of HD space.
    If you have any other large folders of personal data or projects, these should be thinned out, moved, also, to the external hard drive and then either archived to disc and/or deleted off your internal hard drive.
    You may have to Purchase an external FireWire or Thunderbolt hard drive to move these files/data off of your internal drive to the external hard drive and deleted off of the internal hard drive.
    Good Luck!

  • Need a script to delete user files and run on logout.

    Hi folks!
    I'm a total Mac novice so forgive me if I'm vague on anything here. I work in a library and we have recently acquired an iMac running Mountain Lion. The unit is primarily for use by Visually Impaired users however sighted folks can use it as well.
    What I need is something that will delete any files created/downloaded by the sighted users but that will not delete anyone else's files. I tried just using the Guest Account however that also deletes all the system preferences for that account including the dock setup which I need to stay the same.
    If possible I would like this to run on logout.
    For additional points anyone who can also find me something that will run automatically when the users sign in and will sign them out after 30 minutes would super spectacularly awesome.
    Thanks people!

    That being said, if you you still really want to do this you can create a logout hook and write a shell script to remove the files.  See "About Daemons and Services", Appendix B on writing a logout hook.
    But a far easier way is to create Account's login item that will cause a shell script to be launched to delete the files.  You can encapsulate the shell script so it runs as an application that can be added to the Login Items.  One such encapsulator is Platypus.
    Note, rather than delete them, if you want to ensure all the specific plists have specific settings, then create a master set of them and copy the master set into the Preferences directory (being careful to observe ownership and permissions settings of course).

  • PowerShell Script to Delete Files Based on Current Date

    I know by using Get-Date PowerShell will look at the current date.  I would like to make a very basic PS Script which will delete a file older than 8 days based on the current day.  I believe using a if/then function will be necessary. 
    I am very new to scripting so Im not sure how the syntax is written.  All help appreciated.

    Yes, use -Recurse to get subfolders too:
    $Folder = "C:\Users\Me\Backups"
    Get-ChildItem -Path $Folder -Recurse |
    Where { $_.LastWriteTime -lt [DateTime]::Today.AddDays(-8) } |
    Sort LastWriteTime |
    Remove-Item $_ -Force -Confirm:$false
    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________
    Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

  • Help Needed: InDesign Scripting: PDF Multiple Files and Pages Import

    I am looking for a script to merge two PDFs in InDesign CS3 (Mac or PC);
    with an interesting twist for print production.
    We have one PDF that is 408 pages. The second PDF is only one page.
    What we need to accomplish is importing the 408-page PDF file into InDesign,
    then inserting the second 1-page 408 times PDF AFTER every page of the first
    file.
    This will make a 816-page file, where every other page is the "generic" PDF.
    I've used PDFplacer.jsx and it does a great job of bringing in a PDF to
    InDesign. I'm hoping that there is another script to bring in the second
    1-page PDF and have it place this PDF after every page of the file.
    Does anyone know of a script that will accomplish this task?
    I'd also consider having this same scenario done in Acrobat, and then
    sending this new 816 page file to print, if there is any benefit to creating
    the file this way.
    Any help and suggestions would be greatly appreciated.
    Jim Lukens-Gable
    JHL4 at PSU.EDU

    Thanks, Robin,
    I am really a novice at scripting . . . would you be able to modify the script and then send it to me/post it here?
    Thank you!
    Jim L-G

  • HT204053 do i need to unload memory delete files before i install i cloud ?

    i need to free up space on pc   cloud trial???

    Move some files off of your hard drive.

  • Need VB script or Batch file to query Dirty bit

    Hi Friends,
    Could anybody help me in setting up a script which can query Dirty bit on all volumes of 50 servers ?
    Thanks

    Mike / JRV,
    With your help, I could make a script which can find the local drives in a server. But i am blocked to proceed with dirty bit check on those local drives.
    Iam trying my level to find it out :)
    Thanks
    Arun
    You didn't look in the Repository did you?  You also didn't try the code posted above.  We cannot do this for you or would you like someone to remote into your system and do the typing?                     
    fsutil dirty query C:
    ¯\_(ツ)_/¯

  • How to start up from 2nd mac? Need to un-trash deleted files...

    I accidentally put in trash and emptied a folder with weeks of work and I have to do EVERYTHING POSSIBLE get it back. The Mac shops here in L.A. are all minimum 5-7 days repair turnaround - that means I can't work for five days and they may not be able salvage anything anyway.
    Immediately upon realizing what I did, I stopped writing anything to the harddrive - so basically I can't use my computer.
    I've found Norton UnErase is useless unless you had FileSaver previously installed and running regular backups.
    I don't know anyone local with a Mac but I could take my G3 to work, try to start it with my G5 there and run a shareware app called DataRecoveryTool 2.0.3. So far installing DRT on one of my 3 partitions hasn't worked - it doesn't recognize or list any volumes to recover..
    Trouble is, I don't know how to start one Mac from another. I just need an ethernet cable and some keyboard commands, right? I've seen it done long ago.. My cousin in Pasadena has a Powerbook - can I do it with that? What do I need to bring with me?
    Would appreciate all help that would lead me towards re-gaining my data. If you're in LA (SFValley) and have experience - I will pay you to help me! TIA
    BW G3 400   Mac OS 9.2.x  

    Hi, 150mph -
    Firewire Target Disk Mode could achieve what you want - except that the B&W G3 models can not be the Target machine in such a setup, although they can be the Host machine.
    Data Recovery may work only on a disk basis, not a volume basis. Here's a couple of other utilities to try, ones designed to recover data from a mechanically sound drive which refuses to mount.
    Data Rescue
    Virtual Lab
    You may need to pull the drive from the B&W G3 and place it in a multi-drive capable Mac, then use a data recovery utility on the B&W's drive while that other Mac is booted to its normal drive.

  • Need script for moving files to specific directories base on csv

    Hi,
    I have a question. I have about 2000 files (pdf), which I need move to specific directories and subdirectories, which are based on csv file.
    Csv is looking like this:
    filename;directoryname;subdirectoryname;subdirectoryname;.......etc.
    I have a script for creating directories with subdirectories from csv file, but I need this script for moving files to this directories.....
    Thanks a lot for every help.
    Best Regards
    Petr, OS X Mavericks

    private function snapshotLastFrame():void
    gotoAndStop( this.totalFrames );
    _bitmapData                         = new BitmapData( stage.stageWidth, stage.stageHeight );
    _bitmap                              = new Bitmap( _bitmapData );
    _bitmapData.draw ( stage );
    saveImageJPG( _bitmapData, "test.jpg", 96 );
    public function saveImageJPG( bitmapData:BitmapData, fileName:String, quality:int ):void {
                this.jpgEncoder = new JPGEncoder( quality );
                this.fileReference = new FileReference();
                this.fileReference.save( this.jpgEncoder.encode( bitmapData ), fileName + ".jpg" );
    Keep in mind that you need a few extra libraries to be able to create a jpeg.. (AS3CoreLib) can be found at googleCode.

  • Vbscript delete files based on extension on a drive

    Right now i use this batch script to delete files based on extension on drive D: and all folder and subfolder on it every computer restart.
    @echo off
    del /F /S /Q D:\*.jpg            
    del /F /S /Q D:\*.mp3
    del /F /S /Q D:\*.lnk
    del /F /S /Q D:\*.bmp
    I need to change that batch script in to vbscript with same function.
    Help me please..
    sorry for my english..

    righ now i used batch file on startup windows xp, but i want to use vbscript because the cmd will be disable on plan. my batch script like this.
    As mentioned in your duplicated thread, respondents in this forum will gladly help posters with their script problems but they do not write scripts on demand. Here are a couple of options for you:
    Learn how to write VBScripts or PowerShell.
    Run the job as a scheduled task at boot time under an account other than the logon account.

  • Recover deleted files from emptied trash

    Hi I was wondering if there's a way to recover files from the trash if I emptied.In OS 9.x I usually used the Norton but it doesn't works in OSX. Does any body know if there's a free utility to recover deleted files.
    Thanks
    PERCY

    You need File Salvage
    It costs $80 to download, but if you need to recover accidentally deleted files, it works.

Maybe you are looking for

  • How can I remove an app from my iTunes account?

    I have several apps that I purchasesd or added to my account that I know I will never use again. How can I delete these from my iTunes account?

  • Problems with displaying read data from a .lvm file

    Hi all. I aquire data with the PCMCIA card 6036E. I aquire online in Labview 7 and store the data in a .lvm file. When i try to display the same data i aquired before with the "read .lvm file" express vi, the waveform chart redraws itself after an un

  • Data tempalte and parameters

    Hey, I've started learning xml publisher and I've a litle problem/question. I want do something like that: Data template: <dataQuery> <sqlStatement name="Q1"> <![CDATA[ SELECT col1,col2 FROM table WHERE col1= :ColumnNo ]]> </sqlStatement> </dataQuery

  • What the best to buy iPad please

    Hello are you there ?

  • Flash builder 4.0

    Hi I need flash builder 4.0 version any one please provide flash buider4.0 URL