Saturday, January 19, 2019

#1 2018-12-23 06:56:47 am

TheIaMonLyOneHeRe
Member
Registered: 2018-09-16
Posts: 2

Copy a file from one folder to another.

Hello everyone, First of all I would like to apologize if there is a topic here about this I did not find, and besides I am a noob in AppleScript so I would like the help from you, I would like to know how do I copy one file from one specific location to another for example:
I have some photos on the desktop and wanted to select them and copy them to another location using AppleScript, please I know this is a silly example bear in mind that I am learning so please do not be so hard on me, thank you in advance to all .:D

I try this:

Applescript:

on copyFile_(sender)

set myFile to choose file with prompt "Choose a Kext to Install:"
set myFolder to choose folder with prompt "Choose Folder:"
tell application "Finder"
duplicate myFile to myFolder with replacing
end tell
end copyFile_

but I get this error:
Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query
cancelled}
NOTE: IN XCODE 10

Last edited by TheIaMonLyOneHeRe (2018-12-23 06:13:10 pm)

Offline

 

#2 2018-12-26 02:16:42 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 376

Re: Copy a file from one folder to another.

I'm probably not the best one to answer, because your use of

on copyFile_(sender)


makes me think you're using this in an ASObjC capacity and there may be things going on that I don't understand.

But it's been a few days without a response, so:

As vanilla applescript, if you just remove the final underscore and the "sender" argument, what you have works fine for me.

Applescript:


copyFile()


on copyFile()
   
   set myFile to choose file with prompt "Choose a Kext to Install:"
   set myFolder to choose folder with prompt "Choose Folder:"
   tell application "Finder"
       duplicate myFile to myFolder with replacing
   end tell
end copyFile

Last edited by t.spoon (2018-12-26 02:17:28 pm)


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#3 2018-12-27 06:36:02 am

TheIaMonLyOneHeRe
Member
Registered: 2018-09-16
Posts: 2

Re: Copy a file from one folder to another.

Thanks for the answer but it still does not work, I'm doing this as the Action of a button in an AppleScript application in Xcode 10.1 in Mojave, in AppleScript Vanilla works fine but in Xcode it does not.

Offline

 

#4 2018-12-27 01:40:43 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 376

Re: Copy a file from one folder to another.

Sorry. Maybe this should be moved to the "AppleScriptObjC and Xcode" forum:
https://www.macscripter.net/viewforum.php?id=63

Just a wild guess here, but maybe it needs an application to parent the dialogs?

Applescript:


on copyFile:sender
   tell application "Finder"
       set myFile to choose file with prompt "Choose a Kext to Install:"
       set myFolder to choose folder with prompt "Choose Folder:"
       duplicate myFile to myFolder with replacing
   end tell
end copyFile:

Last edited by t.spoon (2018-12-27 01:40:55 pm)


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)