Re: Finder replacing ask
Re: Finder replacing ask
- Subject: Re: Finder replacing ask
- From: Michelle Steiner <email@hidden>
- Date: Thu, 3 Apr 2008 17:14:36 -0700
On Apr 3, 2008, at 3:46 PM, John Mistler wrote:
If a folder already contains a file named "foo" and you try to move
a file named "foo" to that folder, the Finder alerts you and asks if
you want to write over that file. I am trying to script the same
behavior, with
tell application "Finder"
move thisFile to thatFolder replacing ask
end tell
"replacing" is a boolean, so you can't ask directly; all you can do is
say true or false. Therefore you have to check it yourself.
global thisFile, thatFolder
set thisFile to choose file without invisibles
set thatFolder to choose folder
tell application "Finder"
set fileList to name of files of thatFolder
set fileName to name of thisFile
set folderName to name of thatFolder
end tell
if fileName is in fileList then
display dialog "A file named " & fileName & " exists in folder " &
folderName & "." & return & "Do you want to replace it?" buttons
{"Yes", "No"} default button "No" with title "Duplicate File Alert"
if button returned of the result is "Yes" then MoveFile()
else
MoveFile()
end if
on MoveFile()
tell application "Finder" to move thisFile to thatFolder with replacing
end MoveFile
-- Michelle
--
Prius: Kicks Gas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden