Drag and drop script/applet for auto-copy/delete in Finder?

Howdy–

I am new to Applescript and look forward to learning and using it to enhance and automate functions in both OS X and MacOS 9.

To that end, my first project is writing a script to do the following, if possible:
At least once a week I need to copy/move certain files from folders on one volume of a few blue & white G3’s (running MacOS 9.2.2) to differently-named folders on a second volume and then delete the same files from the original folders on the first volume. Sometimes the number of files to be copied/moved can exceed 100 per folder. Needless to say, this can be quite tedious since it needs to be done on several machines.

Can this be done by scripting?

Here are some caveats:

  1. The names of the files to be copied/moved are not the same from week-to-week;
  2. There is a common four-digit + one alpha prefix job number on all files for a particular job no matter what folder the files are in. (for example: 2361F_jobname in the Job folder, 2361F_jobmarks in the Marks folder, 2361F_jobtemplate in the Templates folder. The “2361F_” is the common prefix);
  3. The originating folder and the receiving folder names never change.

I have envisioned a drag and drop applet on the desktop, maybe?

What do you folks think? How do I get started? Any suggestions?

More than happy to provide more details if needed. Thanks to all in advance for your help.

Roger Kidder
Spencer Press, Inc.
An RR Donnelley Company

Model: G3s and G4s running MacOS9.2.2 and OS X 10.3.9
AppleScript: Script Editor 2.0
Browser: Safari 312.6
Operating System: Mac OS X (10.3.9)

Hi Roger,

copying items form one location to another is one of AppleScript’s easiest exercises.
Assuming your have one source folder and a destination folder which contains three folders “Jobs, Marks and Templates”
this script example copies and distributes the files into the three folders and deletes all files of the source folder

property sourceFolder : "path:to:source:folder:"
property destinationFolder : "path:to:destination:folder:"

tell application "Finder"
	duplicate (every file of folder sourceFolder whose name contains "jobname") to folder (destinationFolder & "Jobs:")
	duplicate (every file of folder sourceFolder whose name contains "jobmarks") to folder (destinationFolder & "Marks:")
	duplicate (every file of folder sourceFolder whose name contains "template") to folder (destinationFolder & "Templates:")
	delete items of folder sourceFolder
end tell 

only files will be copied, no folders

Hi.

The Finder command is duplicate, not copy. :slight_smile:

For a droplet, you use a special handler called an open handler.

on open theseItems

	-- Do something with theseItems.

end open

. and save the script as an application. ‘theseItems’ is my name for a parameter variable that automatically receives a list of the dropped items. The method for sorting out where the individual files go wouldn’t use a Finder filter like Stefan’s suggestion, but it’s a bit late at night and I can’t work out exactly where you want things to go.

But the task sounds easily doable. Give us a few more details if you get stuck. :slight_smile:

stupid me !!!

I’ve fixed it above

Thanks