Will this shell script work to delete a folder on boot?

Discussion in 'Mac Programming' started by AmbientChaos, Oct 21, 2014.

  1. AmbientChaos macrumors member

    AmbientChaos

    Joined:
    Feb 11, 2014
    #1
    A certain app is causing empty "Recovered items" folders to appear in the Trash. According to Apple these files are OK to delete.

    I will place this shell script in Login Items so it is deleted on login.

    Will it work?


    rm -r ~/.Trash/Recovered\ items
     
  2. Sciuriware macrumors regular

    Sciuriware

    Joined:
    Jan 4, 2014
    Location:
    Gelderland
    #2
    You would remove EMPTY directories (I hate the term folder) by rmdir
    rm -r is the way to delete non-empty directories with anything in it.
    As you do not know exactly why those remains are left behind I would
    be cautious not to delete too wildly.
    ;JOOP!
     
  3. AmbientChaos thread starter macrumors member

    AmbientChaos

    Joined:
    Feb 11, 2014
    #3
    I would leave it be, but I frequently switch between Windows and OS X and after each restart there is one more Recovered Files directory (currently at Recovered Files #7). It's more annoying than anything, really.

    So you're saying rmdir would be safer, as it removes empty directories, like so?

    Code:
    rmdir ~/.Trash/Recovered\ items
     
  4. Sciuriware macrumors regular

    Sciuriware

    Joined:
    Jan 4, 2014
    Location:
    Gelderland
    #4
    Yes the rm/rmdir family is irreversable: mistakes can't be cured.
    Although I wonder why that directory is left behind in Trash there are
    more programs that create temporary workspace directories
    and don't clean them up. E.g.: Crossover.
    Then again, after some sessions you will find always something of your own
    in the Trash that you might get rid of.
    Be careful with (hidden) login scripts and programs: you'll forget about
    their existence until in the future circumstances change and the thing is still there.
    ;JOOP!
     

Share This Page