Copy file to my bundle

Hi, i’m trying to choose a file and copy it to my bundle resource folder.

One thing very important is also to get the name and extension of the choosen file


		set myBundlePath to (current application's class "NSBundle"'s mainBundle()'s bundlePath())
		set dossierBundleRessource to myBundlePath & ":Contents:Resources:" as string
		
		tell application "Finder" -- permet de recuperer chemin et nom du fichier choisi
			set choixFichierImageAgence to choose file with prompt "Merci de choisir le fichier bandeau !"
			set nomFichierImageAgence to name of infoChoixImgAgence as string
			set pathFichierImageAgence to path of infoChoixImgAgence as string
			
			-- copy le fichier dans le bundle
			move choixFichierImageAgence to dossierBundleRessource
		end tell

It doesn’t work. I’m start to be crazy

bundlePath() returns a POSIX path, so tacking on colon-delimited folder names isn’t going to work. But all you really need is:

set dossierBundleRessource to current application's NSBundle's mainBundle()'s resourcePath()

Then your move line needs some attention, perhaps:

move choixFichierImageAgence to folder (((dossierBundleRessource as text) as POSIX file) as text)

It’s not recommended to copy files into the bundle because of two reasons. 1) Apple guidlines tells you not to use the application bundle as a ‘workspace’. 2) if the application is installed in applications folder then half of the users can’t even use your program (by default the application folder is read only for non-admin users).

It doesn’t want to compile. Says "except end of line but found “(”

tell application “Finder” to move choixFichierImageAgence to folder (((dossierBundleRessource as text) as POSIX file) as text)

:slight_smile:
Sometime, i feel so stupid

Thank to all