Finder: copy Folder to hidden Folder...

Greetings

I try to copy an existing folder InputFolder to a preliminarily created hidden (invisible) destinationFolder:


set InputFolder to alias (((path to movies folder) as text) & "Data")
set destinationFolder to alias (((path to movies folder) as text) & ".Temp")
tell application "Finder" to set ImportedFolder to (duplicate folder InputFolder to folder destinationFolder with replacing) as string

I get the error message “Finder got an error: Can’t make alias “… :.Temp:” into type folder.”.

However if I set destination to preliminarily created non-hidden (non-invisible) I get no error:

set InputFolder to alias (((path to movies folder) as text) & "Data")
set destinationFolder to alias (((path to movies folder) as text) & "Temp")
tell application "Finder" to set ImportedFolder to (duplicate folder InputFolder to folder destinationFolder with replacing) as string

Think this error is of same sort as this one.

Could you help me please to figure out the reason and possible sollution?

Try this.


set InputFolder to quoted form of POSIX path of (((path to movies folder) as text) & "Data")
set destinationFolder to quoted form of POSIX path of (((path to movies folder) as text) & ".Temp")
do shell script "/usr/bin/ditto " & InputFolder & space & destinationFolder

Thank you, Craig!
However the stiff requirement I have is to show (Finder) copy progress bar, which is not the case while using ditto

What is the code you are using for the progress bar?

I don’t use any special code. When Finder duplicates something it shows the standard copy progress bar.

If you want to use vanilla AS, the original code is pretty close; you just need to nix the folder references in the last line.

tell application "Finder" to set ImportedFolder to (duplicate InputFolder to destinationFolder with replacing) as string

Dear Marc,
Could you could share info about what “vanilla” is?
Also I couldn’t get your point - tried your code, but still does not work…

Vanilla AppleScript is AS without Unix touches/shell scripts. You say the code didn’t work… you did pair my edit with the first two statements in your original post, correct? It tests as working under Tiger, 10.4.11.

Tried this one (first two lines from my original post and the third one is yours):


set InputFolder to alias (((path to movies folder) as text) & "Data")
set destinationFolder to alias (((path to movies folder) as text) & ".Temp")
tell application "Finder" to set ImportedFolder to (duplicate InputFolder to destinationFolder with replacing) as string

Still get the error message “Finder got an error: Can’t make alias “… :.Temp:” into type folder.”.

The same code but with error handling:

try
	set InputFolder to alias (((path to movies folder) as text) & "Data")
	set destinationFolder to alias (((path to movies folder) as text) & ".Temp")
	tell application "Finder" to set ImportedFolder to (duplicate InputFolder to destinationFolder with replacing) as string
on error errorText number errorNumber
	display dialog "Error number:   " & errorNumber & return & return & "Error text:   " & errorText
end try

returns error number -1700 with the same error text.

All this has been tested on 10.5.8 with AppleScript 2.0.1.

Any other ideas?

Hello AKazak,

Finder scripting won’t let you refer to invisible “files” or invisible “folders”, but it will let you refer to them as “item

hth

Nice idea, but…

The following script works fine:


tell application "Finder"
	set InputFolderItem to item (((path to movies folder) as text) & "Data")
	set destinationFolderItem to item (((path to movies folder) as text) & "Temp")
	duplicate InputFolderItem to destinationFolderItem with replacing
end tell

However the following one:


tell application "Finder"
	set InputFolderItem to item (((path to movies folder) as text) & "Data")
	set destinationFolderItem to item (((path to movies folder) as text) & ".Temp")
	duplicate InputFolderItem to destinationFolderItem with replacing
end tell

fails with error: “Finder got an error: Can’t make item “.Temp” of folder “Movies” of folder … of startup disk into type folder.”.

It seems like Finder doesn’t like to get an invisible (hidden) folder as destination - the opposite duplication works fine without errors:


tell application "Finder"
	set InputFolderItem to item (((path to movies folder) as text) & "Data")
	set destinationFolderItem to item (((path to movies folder) as text) & ".Temp")
	--	duplicate InputFolderItem to destinationFolderItem with replacing
	duplicate destinationFolderItem to InputFolderItem with replacing
end tell

Hello,

this works for me (OSX.4.11)

try
	set MovieFolder to (path to movies folder) as text
	set InputFolder to alias (MovieFolder & "Data")
	set destinationFolder to alias (MovieFolder & ".Temp")
	tell application "Finder" to (duplicate InputFolder to item destinationFolder with replacing)
on error e
	display dialog e
end try

Unfortunately this code gives the error message “Finder got an error: Can’t make alias “… :.Temp:” into type folder.” for me (10.5.8). :confused:

All this is also related to Finder move command. :frowning:

All manipulations with invisible (hidden) folder work fine if made in drag-and-drop manner by means of mouse and modifier keys (Command, Option, Control, Shift).

Unfortunately such Finder behavior seems to be either a bug or one of “restrictions due to the aggressive security policies” of Leopard, as concluded here. :o

I consider using ditto, cp or mv, but I need to display a progress bar on the screen…
Could you advice me any way to organize a progress bar while running shell script in background please?

Have you considered writing an AppleScript Studio application to handle this. It is very easy to do progress bars and there are many tutorials to learn from.

Here is one to get you started.

Thank you Craig for the starting hint!
Before installation of such monster as XCode let me ask you about main idea of transferring shell script command execution state (cp for example) to AppleScript Studio application with progress bar?