Saturday, September 23, 2017
  • Index
  •  » OS X Finder
  •  » How can I move files in Folder A to the trash, except for Folder B?

#1 2005-10-12 07:00:27 am

julifos
Administrator
From:: Malasaña, Madrid
Registered: 2002-11-20
Posts: 2014

How can I move files in Folder A to the trash, except for Folder B?

There are various ways to go about this. Here's one example:

Applescript:

property doNotDelete : {alias "Macintosh HD:Folder B:", alias "Macintosh HD:Folder C:", alias "Macintosh HD:Folder D:"}

tell application "Finder"
   move every item of doNotDelete to desktop -- Moves Folders B, C and D to the Desktop
   move every item of alias "Macintosh HD:Folder A:" to trash -- Moves everything else in Folder A to Trash
   move every item of doNotDelete to alias "Macintosh HD:Folder A:" -- Moves Folders B, C and D back to their original location (Folder A)
end tell

Note that we used "alias" references to the doNotDelete folders in the previous script! This allows the script to keep track of the folders which are moved. For example, if the first line of the script above had been written like this...

property doNotDelete : {folder "Macintosh HD:Folder B:", folder "Macintosh HD:Folder C:", folder "Macintosh HD:Folder D:"}

... Using "alias" allows the script to complete the "move" command because it kept track of where the folders were moved to when they temporarily went to the Desktop.

It's important to note that any object which an alias refers to must already exist in order for the script to compile.


Filed under: Finder

Offline

 
  • Index
  •  » OS X Finder
  •  » How can I move files in Folder A to the trash, except for Folder B?

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)