Re: New to OS 10 help Please
Re: New to OS 10 help Please
- Subject: Re: New to OS 10 help Please
- From: Andrew Oliver <email@hidden>
- Date: Wed, 02 Apr 2003 09:29:39 -0800
The question really is what do you want to do with items that have the same
name?
Checking the Finder's dictionary, you can see that the 'move' command
accepts an optional 'replacing' flag. If set (by appending 'replacing yes'
at the end of the move command), the Finder will replace files with
duplicate names.
If you don't want that, you can do whatever you want with the file by
enclosing the move statement in a try/on error/end try block. Maybe you
want to warn the user:
try
move aFile to folder destFolder
on error -- oops, couldn't move the file
display dialog ("Couldn't move " & name of aFile as string) buttons {"OK"}
end try
Or maybe you don't care - in which case eliminate the line that displays a
dialog.
The options are almost limitless.
Andrew
:)
On 4/2/03 7:58 AM, "Easthope, John R" <email@hidden> wrote:
>
What do you do about files that may have the same name?
>
>
_________________________________________
>
>
John Easthope
>
School Technology Support Analyst
>
Calgary Board of Education
>
Help Desk: 294-8111 Fax: 294-8689
>
Email: email@hidden
>
_________________________________________
>
>
>
>
> ----------
>
> From: Andrew Oliver
>
> Sent: Tuesday, April 1, 2003 4:32 PM
>
> To: email@hidden; email@hidden
>
> Subject: Re: New to OS 10 help Please
>
>
>
> The simplest way is not to select any items at all
>
>
>
> Since it looks like you're trying to collapse multiple subfolders into one
>
> folder, a simple recursive script will do the job much better:
>
>
>
> property destFolder : "Macintosh HD:MOVED" -- or wherever the destination
>
> folder is
>
>
>
> tell application "Finder"
>
> set sourceFolder to folder "MOVE ME" -- of disk "blah", etc.
>
> my moveFilesFrom(sourceFolder)
>
> end tell
>
>
>
> on moveFilesFrom(thisFolder)
>
> tell application "Finder"
>
> set filesToMove to every file of thisFolder
>
> repeat with aFIle in filesToMove
>
> move aFIle to folder destFolder
>
> end repeat
>
> set subFolders to (every folder of thisFolder)
>
> repeat with aFolder in subFolders
>
> my moveFilesFrom(aFolder)
>
> end repeat
>
> end tell
>
> end moveFilesFrom
>
>
>
> The idea here is that the script tells the finder to move 'every file' in
>
> the folder. It then gets a list of every folder inside the current folder
>
> and calls itself. This will repeat through all subfolders until all files
>
> are moved.
>
>
>
> It doesn't rely on any kind of object selection in the Finder, so it can
>
> run
>
> quietly in the background while the user is performing other tasks -
>
> something you can't do it you're trying to move the selected item in the
>
> Finder.
>
>
>
> On 4/1/03 11:53 AM, "email@hidden" <email@hidden> wrote:
>
>
>
>> Having just migrated to OS X I have a script (from OS9 ) that I use a
>
> lot and
>
>> can't figure out how to get it to work in OS X. I am trying to pull all
>
> the
>
>> files out of a large number of folders and put them into one folder. I
>
>> understand finder is different in 10 but can't figure out how to just
>
> select
>
>> the files and not the folders.... I get "Finder got an error: Can't set
>
>> expanded of selection to true" from the following script....
>
>> tell application "Finder"
>
>> with timeout of 300 seconds
>
>> activate
>
>> select {every folder of folder "MOVE ME"}
>
>> set expanded of selection to true
>
>> select {every item of every folder of folder "MOVE ME"}
>
>> move selection to folder "MOVED"
>
>> end timeout
>
>> end tell
>
>>
>
>> Thanks for any help in this matter.
>
>> Mark
>
>> email@hidden
>
>> _______________________________________________
>
>> applescript-users mailing list | email@hidden
>
>> Help/Unsubscribe/Archives:
>
>> http://www.lists.apple.com/mailman/listinfo/applescript-users
>
>> Do not post admin requests to the list. They will be ignored.
>
> _______________________________________________
>
> applescript-users mailing list | email@hidden
>
> Help/Unsubscribe/Archives:
>
> http://www.lists.apple.com/mailman/listinfo/applescript-users
>
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.