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
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
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.
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
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).
All this is also related to Finder move command.
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.
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?