And here I thought it meant something like, "turn away (back) now for being in a relationship with me is perilous and doomed to failure." Project much, do I?
It's short, sweet and to the point, but: How will you invoke it? Keyboard shortcut? Also, what if one of the items in "myFolder" has the same name as one of the items in "container of myFolder"? Mine (above) takes care of these problems albeit in a more roundabout kind of way. Saving it as a service lets you right-click a folder and choose it, it also tries each item individually and handles the possibility of duplicate names gracefully. My script is ugly, though! ;)
I took a bit of a different approach (which also handles multiple folder selections). I used Automator so I could make a new "Service" that accepts folders. This way it shows up in the context menu if you right-/control-click on a folder.
It's pretty easy, launch Automator and choose "Service" as the template. Choose "Selected Folders" from the "Service receives:" dropdown and "Finder" from the "in" dropdown. Drag a "Get Selected Finder Items" action to the workflow and then a "Run Applescript" one below it.
Here's the (quick and dirty) script I came up with:
on run {input, parameters}
set errorTripped to false
repeat with anAlias in input
tell application "Finder"
if kind of anAlias is "Folder" then --make sure the target item is a folder
set dest to container of anAlias --the parent of the target, this is where we'll move the contents of 'anAlias'
set theFiles to every item of anAlias --get all the files/folders in the target folder
--move all files and folders up to the parent folder
repeat with aFile in theFiles
set itemKind to "file"
if (kind of aFile is "Folder") then set itemKind to "folder"
try
move aFile to dest --try to move the current file
on error
--most likely reason this would error out is because an item with the same name as 'aFile' already exists there. We could prompt for a new name, or just append something to the name, but for simplicity's sake, we'll just note the error and not delete the target folder, leaving the duplicate named items where they were.
display dialog "Could not move " & itemKind & " '" & the (name of aFile) & "' to parent folder, most likely there is already a file/folder with the same name."
set errorTripped to true
end try
end repeat
--Make sure there were no errors and that the target folder is now empty
if (errorTripped is false and (count of (every item of anAlias)) is 0) then
delete anAlias
end if
end if
end tell
end repeat
if (errorTripped is true) then
display dialog "The target folder was not deleted because one or more items could not be moved to the parent folder."
end if
end run
The script may be a bit sloppy, but doing it one file/folder at a time has the benefit of not bailing in the middle if a file/folder with the same name already exists in the parent directory. It will move every folder/file that has a "unique in the parent directory" name and only delete the "target" folder if no errors occurred and the folder is empty.
Disclaimer: this is quick and dirty, I tested it a bit but I am not responsible if you use it and it fucks something up! ;)
use a "Run AppleScript" action to actually move the files. I'll give it a few minutes and if I get it working well I may post it somewhere for you to download if you like.
In OS X, at least, this could be accomplished with a trivial amount of effort in Automator and a little AppleScript knowledge. So, too, would the opposite ("select files > create folder and move selected files to it").
Yeah, but weh will you pahk the cah?
And here I thought it meant something like, "turn away (back) now for being in a relationship with me is perilous and doomed to failure." Project much, do I?
It's short, sweet and to the point, but: How will you invoke it? Keyboard shortcut? Also, what if one of the items in "myFolder" has the same name as one of the items in "container of myFolder"? Mine (above) takes care of these problems albeit in a more roundabout kind of way. Saving it as a service lets you right-click a folder and choose it, it also tries each item individually and handles the possibility of duplicate names gracefully. My script is ugly, though! ;)
I liked the suggestion to call this action "Dissolve Folder" so that's what I saved mine as...
I took a bit of a different approach (which also handles multiple folder selections). I used Automator so I could make a new "Service" that accepts folders. This way it shows up in the context menu if you right-/control-click on a folder.
It's pretty easy, launch Automator and choose "Service" as the template. Choose "Selected Folders" from the "Service receives:" dropdown and "Finder" from the "in" dropdown. Drag a "Get Selected Finder Items" action to the workflow and then a "Run Applescript" one below it.
Here's the (quick and dirty) script I came up with:
The script may be a bit sloppy, but doing it one file/folder at a time has the benefit of not bailing in the middle if a file/folder with the same name already exists in the parent directory. It will move every folder/file that has a "unique in the parent directory" name and only delete the "target" folder if no errors occurred and the folder is empty.
Disclaimer: this is quick and dirty, I tested it a bit but I am not responsible if you use it and it fucks something up! ;)
use a "Run AppleScript" action to actually move the files. I'll give it a few minutes and if I get it working well I may post it somewhere for you to download if you like.
In OS X, at least, this could be accomplished with a trivial amount of effort in Automator and a little AppleScript knowledge. So, too, would the opposite ("select files > create folder and move selected files to it").
I thought she was the one we couldn't do business with.
Good call! Let's hope someone can make a much, much, much better version of that one, too.
End of this list.
Back to top