absolute to relative path

hi
with all your help I got this script to work that copy files from a location to to any external drive


	tell application "Finder" to set disks_ to name of disks whose startup is false
	set chosen_ to choose from list disks_ with prompt "Choose a volume to copy to."
	if chosen_ is false then return -- user canceled, quit script 
	set originalFile to "Macintosh HD:Users:Shared:pdf:spec:01.pdf"
	set Newname to "New_name"
	do shell script "ditto " & quoted form of (POSIX path of originalFile) & "  " & (POSIX path of chosen_)

notice that path to file “01.pdf” is absolute and I want it to be relative
here is what I am trying to do


	tell application "Finder" to set disks_ to name of disks whose startup is false
	set chosen_ to choose from list disks_ with prompt "Choose a volume to copy to."
	if chosen_ is false then return -- user canceled, quit script 
     set myFolder to (container of (container of (path to me))) as text
	set originalFile to (myFolder & spec:01.pdf)
	set Newname to "New_name"
	do shell script "ditto " & quoted form of (POSIX path of originalFile) & "  " & (POSIX path of chosen_)

but it doesn’t work
please give some suggestions
hope you got it what i want to do.

thanks

There’s two problems with your script as quoted that prevent it from working.

Specifically, in the lines:

set myFolder to (container of (container of (path to me))) as text 

‘container’ is a Finder object and therefore this code needs to be run in a ‘tell application “Finder”’ block. If you wrap the entire script in a Finder block it should work better.

Secondly (and this may just be a typo in the post), the line:

set originalFile to (myFolder & spec:01.pdf) 

You need to quote ‘spec:01.pdf’ since it’s a literal string:

set originalFile to (myFolder & "spec:01.pdf") 

Finally, while not a problem per se, you should quote all POSIX paths to make sure they’re shell-safe - you currently only quote the source filename, not the destination. As a result the ditto command will fail if the destination pathname includes spaces or other special characters. So, instead of:

do shell script "ditto " & quoted form of (POSIX path of originalFile) & "  " & (POSIX path of chosen_)

do:

   do shell script "ditto " & quoted form of (POSIX path of originalFile) & " " & (quoted form of POSIX path of chosen_)

thanks camelot
I changesd my script according to your suggestion but got this error

but you know what the path above is exectly fine but for some reason it is not seeing the 01.pdf.
Here is the script i changed

tell application "Finder"
	set disks_ to name of disks whose startup is false
	set chosen_ to choose from list disks_ with prompt "Choose a volume to copy to."
	if chosen_ is false then return -- user canceled, quit script 
	set myFolder to (container of (container of (path to me))) as text
	set originalFile to (myFolder & "lounge:spec:01.pdf")
	set Newname to "New_name"
	do shell script "ditto " & quoted form of (POSIX path of originalFile) & "  " & (quoted form of POSIX path of chosen_)
end tell

and when i run this it works

tell application "Finder"
	set myFolder to (container of (container of (path to me))) as text
	set originalFile to (myFolder & "lounge:spec:01.pdf")
	open originalFile
end tell

So please give me some suggestion
thanks

i really want to know whats wrong
please reply

thanks

i tried and experiment lot but it is not looking at the target file
even it there.
please give suggestion
here is what iam trying

tell application "Finder" 
   set disks_ to name of disks whose startup is false 
   set chosen_ to choose from list disks_ with prompt "Choose a volume to copy to." 
   if chosen_ is false then return -- user canceled, quit script  
   set myFolder to (container of (container of (path to me))) as text 
   set originalFile to (myFolder & "lounge:spec:01.pdf") 
   set Newname to "New_name" 
   do shell script "ditto " & quoted form of (POSIX path of originalFile) & "  " & (quoted form of POSIX path of chosen_) 
end tell

i think it may be something wrong with “ditto” command because this script working well

tell application "Finder" 
   set myFolder to (container of (container of (path to me))) as text 
   set originalFile to (myFolder & "lounge:spec:01.pdf") 
   open originalFile 
end tell

reply me even if it is not possible so that i can stop working on it