I’m trying to copy a folder into a Dashboard Widget bundle. Everything is fine if I’m copying the folder to a folder inside the widget bundle:
duplicate folder my_folder to "Macintosh HD:Users:steve:Desktop:Test.wdgt:destination_folder" with replacing
However, I only want to copy the folder into the main widget bundle”not into a folder inside the bundle.
Currently, I have:
tell application "Finder"
duplicate folder my_folder to "Macintosh HD:Users:steve:Desktop:Test.wdgt" with replacing
end tell
Unfortunately, I get an error: ‘Finder got an error: Can’t make “Macintosh HD:Users:steve:Desktop:test.wdgt” into type folder.’… I’ve tried various different things (such as “file package”) with no success.
Is there a way to do this without having to resort to executing a Terminal command?
I don’t know about a Finder solution, but you could just use the fine and built-in «ditto» command to get things done. Here is an example, which can be easily modified to suit your own needs:
set sourcefolder to quoted form of "/Users/martin/Desktop/test/"
set destfolder to quoted form of "/Users/martin/Desktop/Test.wdgt/test/"
set command to "ditto " & sourcefolder & " " & destfolder
do shell script command
Thanks, Martin! I’ll try that if I can’t get it working in Finder. By the way, do you know the difference between ditto and cp (from my little bit of searching, it seems that ditto preserves resource forks & HFS meta-data, whereas cp does not)?
Thank you, StefanK, but Finder doesn’t treat packages as folders. As said before, everything works fine when the destination folder is a folder within the bundle”but I want the destination to be the bundle itself. When I take the “:destination_folder:” part out of your example code:
duplicate folder my_folder to folder ((path to desktop as text) & "Test.wdgt") with replacing
…I get another error: 'Finder got an error: Can’t set folder “Macintosh HD:Users:steve:Desktop:Test.wdgt” to folder Macintosh HD:Users:steve:Desktop:Test.wdgt".