Moving a Folder into a Bundle

Hello,

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?

Thanks,
Quill

Operating System: Mac OS X (10.5)

Hi Quill,

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

Hi Quill,

of course you get an error, because you try to copy a folder to a literal string,
use also the specifier folder for the destination


tell application "Finder"
	duplicate folder my_folder to folder ((path to desktop as text) & "Test.wdgt:destination_folder:") with replacing
end tell

Note: path to desktop is a “shortcut” to the current desktop

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".

What does this mean?

Thanks,
Quill

a widget is a special case. It is a package folder but is treated as a document file.
The suggested solution of Martin is the proper way.