Saving exported doc from indesign into specific dir

The exported document is a jpg file. The file should be saved in a specific folder with the same name of the document in the shared documents directory.
The problem is that the file isn’t saved in the specific folder, its saved in the root of the shared documents. Can someone sort this out for me? Here is my script.


tell application "Adobe InDesign CS3"
	set docu to active document
	set docName to name of docu
	
	--filtering the extension out the document's name if any
	if docName contains ".indd" then
		set countCharacter to count every character of docName
		set countResult to countCharacter - 5
		set docName to characters 1 thru countResult of docName as string
	end if
	
	--create folder with name of document in the shared folder 
	do shell script "mkdir -p /Users/Shared/" & docName
        delay 1
	set thePath to "Macintosh HD:Users:Shared:" & docName
	
	--exporting the document as jpg
	tell JPEG export preferences
		set properties to {JPEG Quality:low, JPEG Rendering style:baseline encoding}
	end tell
	tell docu
		export format JPG to (thePath & ".jpg") without showing options
	end tell
end tell

Hi,

the name must be twice in the path like “Mac HD:Users:Shared:docname:docname.pdf”
try this


set sharedFolder to path to shared documents as text
tell application "Adobe InDesign CS3"
	set docu to active document
	set docName to name of docu
	
	--filtering the extension out the document's name if any
	if docName ends with ".indd" then set docName to text 1 thru -6 of docName
	
	--create folder with name of document in the shared folder 
	set newFolder to (sharedFolder & docName & ":")
	do shell script "mkdir -p " & quoted form of POSIX path of newFolder
	
	--exporting the document as jpg
	tell JPEG export preferences
		set properties to {JPEG Quality:low, JPEG Rendering style:baseline encoding}
	end tell
	tell docu
		export format JPG to (newFolder & docName & ".jpg") without showing options
	end tell
end tell