:DHello All,
Can someone help me out with some script.
This is probably really basic and I apologise if it is, can you direct me where to look.
I need to move a set of folders to the trash on a specific day each week, then empty trash (this I have figured out!) and recreate ther folders in the old location.
I keep coming up against a brick wall with the first part of the script.
i think this way would save the time of having to recreate the folders
tell application "Finder"
try
move every item in folder "untitled folder" of folder "Desktop" of folder "USername" of folder "Users" of startup disk to the trash
move every item in folder "untitled folder 2" of folder "Desktop" of folder "USername" of folder "Users" of startup disk to the trash
move every item in folder "untitled folder 3" of folder "Desktop" of folder "USername" of folder "Users" of startup disk to the trash
end try
empty the trash
end tell
and an easy way to get those paths (of folder of folder of foder blablabllba)
is to
select a folder then
open script editor and do this
tell application "finder"
set thefolder to selection
end tell
I agree with bigkm. As long as the folders will keep the same name, you should delete the contents. Of course, sometimes new folder creation is desired due to creation date or renaming. If you are not exited about the prospect of “hardwiring” (typing in the path to the folders), which you will have to do if you trash files or folders, you can take one other route. You can drop a folder on the application, and it will then be a “target” folder. That avoids hardwiring and selection prompts… As far as scheduling for routine empties, we must ask, are you sure? Not even a user prompt will come up to verify?
SC
This becomes a droplet when saved as an application, not staying open. It will store up to 4 locations and can be increased by adding a little code if needed.
property TargetFolders : {}
try
tell application "Finder"
move every item in folder (item 1 of TargetFolders) to the trash
move every item in folder (item 2 of TargetFolders) to the trash
move every item in folder (item 3 of TargetFolders) to the trash
move every item in folder (item 4 of TargetFolders) to the trash
end tell
end try
tell application "Finder"
empty the trash
end tell
on open DroppedItem
set ThisFolder to DroppedItem as string
set TargetFolders to TargetFolders & ThisFolder
set counter to 1
try
repeat with Folds in TargetFolders
display dialog "The current folders targeted for deletion are: " & (item counter of TargetFolders)
set counter to counter + 1
end repeat
end try
end open
*Edit: The script stores Folder locations by dropping any folder, whose path will then be stored in TargetFolders. Run the script to delete items of folders.
SC