I’m trying to make a droplet that will take every file of any folder inside the folder you dropped, move them to the parent folder, and delete the original, now empty folder. This as far as I got.
on open thisFolder
display dialog "Are you sure you want to move files in all subfolders into the folder you dragged?"
set allFiles to every item of thisFolder
if some item of allfiles has kind "Folder" then
set subfolders to true
else if false then
set subfolders to false
end if
end open
The “some item of allfiles has kind “Folder”” part won’t compile. I think it’s simple enough to understand what I want, so I’ll leave it to you to figure out the rest.
Obviously, the “else if false” is just a place holder.
So what you’re saying is that that will give me a list of every file in that folder and every subfolder? If so then this script should work, but I can’t test it at the moment because that would require me to save it as an application, and this computer is forbidden from opening applications that are not specifically enabled. I also took the liberty of adding a few safeguards, such as the ability to copy the folder, and also the ability to run it as a script as well as a droplet.
on open thisFolder
tell application "Finder"
try
set copyFolder to button returned of (display dialog "Are you sure you want to move files in all subfolders into the folder you dragged? This will completely destroy your organization." with icon caution buttons {"Run", "Run on a copy", "Don't run"} cancel button "Don't Run" default button 3)
if copyFolder is "Run" then
set allFiles to files of entire contents of thisFolder
move allFiles to thisFolder replacing ask
display dialog "The folder hirearchy has been destroyed!"
else if copyFolder is "Run on a copy" then
if (path to desktop folder as text & "Organized Folders:") exists then
duplicate folder thisFolder to (path to desktop folder as text & "Organized Folders:")
else
make folder (path to desktop folder as text & "Organized Folders:")
duplicate folder thisFolder to (path to desktop folder as text & "Organized Folders:")
end if
set allFiles to files of entire contents of thisFolder
move allFiles to thisFolder replacing ask
display dialog "Your folder has been duplicated into an \"Organized Folders\" folder on your desktop, and the original's folder hirearchy has been destroyed."
end if
on error
display alert "You must drop a folder, not a file"
end try
end tell
end open
on run
set thisFolder to (choose folder with prompt "Choose the folder whose orgainzation to destroy:")
tell application "Finder"
try
set copyFolder to button returned of (display dialog "Are you sure you want to move files in all subfolders into the folder you dragged? This will completely destroy your organization." with icon caution buttons {"Run", "Run on a copy", "Don't run"} cancel button "Don't Run" default button 3)
if copyFolder is "Run" then
set allFiles to files of entire contents of thisFolder
move allFiles to thisFolder replacing ask
display dialog "The folder hirearchy has been destroyed!"
else if copyFolder is "Run on a copy" then
if (path to desktop folder as text & "Organized Folders:") exists then
duplicate folder thisFolder to (path to desktop folder as text & "Organized Folders:")
else
make folder (path to desktop folder as text & "Organized Folders:")
duplicate folder thisFolder to (path to desktop folder as text & "Organized Folders:")
end if
set allFiles to files of entire contents of thisFolder
move allFiles to thisFolder replacing ask
display dialog "Your folder has been duplicated into an \"Organized Folders\" folder on your desktop, and the original's folder hirearchy has been destroyed."
end if
on error
display alert "You must drop a folder, not a file"
end try
end tell
end run
One more thing: How do I delete the now empty folders after I’m done?
Thanks!
Another more thing: Can I make it so that the folder will be duplicated into the same parent folder as the one you select, with " Organized" added to the name?
The same way really has you accessed all the files. But this time delete “folders of entire contents of blah blah blah”
I’d imagine a shell script might be an easier way of doing this otherwise you may have to duplicate it to another location change its name then move it into the parent folder that way.