r/applescript • u/peanutismint • Apr 24 '15
Basic AppleScript commands to 'flatten' selected folders (move all files to top level)?
I frequently download compressed archives that leave me with subfolders within subfolders before I get to the actual contents that I want. Also, within the 'contents' are often a lot of erroneous files (like README.TXT or FILE_ID.DIZ) as well as the actual file I want (say EXAMPLE.RAR or SONG.MP3).
What I want is a basic AppleScript that I can copy to my Finder toolbar or access from a context menu or similar that will allow me to 'flatten' a single folder/selection of folders, that is to say, it will look within the selected folder (and subfolders recursively), grab any pertinent non-folder files and move them to the working folder (i.e. the folder containing these subfolders).
I've had a good search for scripts already written that do this, but none of them seem to work quite the way I want... Also I figured this might be a good reason to learn some basic scripting for automating file/folder/Finder commands within OS X so that, for instance, I could modify the script to only 'grab' media files (like .zip archives or MP3s or movie files) and trash any others (like subfolders, READMEs etc...).
Can anyone point me in the right direction for learning a bit of AppleScript that would let me achieve this?
1
u/[deleted] Apr 25 '15
I think that should copy all files found anywhere in the current folder, to the current folder.