Automating deleting resource forks.

Discussion in 'Mac Programming' started by VideoBeagle, Jun 26, 2014.

  1. VideoBeagle macrumors 6502a

    Joined:
    Aug 17, 2010
    Location:
    App Q&A testing by request.
    #1
    I have a drive with a lot of mp3's in folders.

    It's littered with the resource forks.

    The programs I once used to clean folders no longer work in mavericks, because of course they don't.

    Googling for answers has failed....so I decided to try doing some scripting and/or automating.

    This script works for individual folders

    Code:
    set srcFolder to choose folder
    set file_path to srcFolder as alias as string
    set pfile_path to POSIX path of file_path
    tell application "Terminal"
    	activate
    	delay 1
    	do script "cd \"" & pfile_path & "\""
    	delay 1
    	do script "ls -a> test.txt" in window 1
    	do script "rm ._*" in window 1
    	do script "ls -a> test2.txt" in window 1
    	delay 1
    	quit "Terminal"
    end tell
    but I've failed in figuring out how to get Applescript to travel through subfolders.

    In Automator I actually have a Zap Resource Fork action....which seems to no longer work, and while it can traverse subfolders, getting it to execute the script in a useful way isn't really going my way either.

    So, I guess the question I have before I invest more time in this...is there a better way to do this?
     
  2. Madd the Sane macrumors 6502a

    Madd the Sane

    Joined:
    Nov 8, 2010
    Location:
    Utah
    #2
    You can use the xattr command to remove resource forks. I can't remember the UTI to delete.
     
  3. VideoBeagle thread starter macrumors 6502a

    Joined:
    Aug 17, 2010
    Location:
    App Q&A testing by request.
    #3
    Thanks...I'll look into that.

    (It's academic now, I found a program Blue Harvest that does the job.)
     
  4. JustMartin macrumors 6502a

    Joined:
    Feb 28, 2012
    Location:
    UK
    #4
    you could also use the find command action for this as well

    Code:
    find  . -name "_*" rm {} \;
    
     
  5. VideoBeagle thread starter macrumors 6502a

    Joined:
    Aug 17, 2010
    Location:
    App Q&A testing by request.
    #5
    That's in the shell script part? The bigger question, I think is navigating through the file strucutre.

    (I think I could cobble together a shell or perl script that does that pretty easily...it's the applescript or automator ways so I'd have an easy app that I think I stumble on)
     
  6. JustMartin macrumors 6502a

    Joined:
    Feb 28, 2012
    Location:
    UK
    #6
    Yes, that's in the shell script part and it automatically goes down the folder hierarchy from the current or provided folder.

    Not sure you need applescript after that as this does it all in one command or shell script (which you could give a memorable name to).
     

Share This Page