Open file in subfolder

Hey guys I need help one more time. I am trying to select a folder in which I have a subfolder inside the subfolder is a .qxd document. I want to open the .qxd and then close it. I want this process to keep repeating until it has gone through all the subfolder and opened and closed all of the .qxd documents. I only want it to open .qxd files and not any other files there might be other graphic files that are linked to the file and I don’t want those to open just want to keep them linked to the document so if there is something else besides .qxd don’t want it to do anything to the graphic files.

Folder 1
subfolder1
.qxd file
subfolder2
.qxd file
subfolder3
.qxd file
subfolder4
.qxd file

set SourceFolder to (Choose folder with prompt) as text
set filelist to list folder SourceFolder without invisibles
repeat with thisFileName in filelist
set this filename to thisFileName as string
tell application “Finder”

Based on your post I think this might work. Point it at your main folder, the one represented in your post as Folder 1. It will cycle thru the sub folders and open only the files whose type is equal to “XDOC”.

set SourceFolder to (choose folder with prompt "")
tell application "Finder" to set FolderList to get the name of every folder of SourceFolder
repeat with thisFolder in FolderList
	set thisSubFolder to (SourceFolder as string) & thisFolder as string
	tell application "Finder" to set filelist to (get the name of every file of folder thisSubFolder whose file type = "XDOC") as list
	repeat with thisFileName in filelist
		set thisPath to (thisSubFolder as string) & ":" & thisFileName as string
		tell application "QuarkXPress™"
			--activate--(optional)
			open thisPath
			close document 1
		end tell
	end repeat
end repeat

(*optionals for Quark open command
		use doc prefs yes/no/ask -- use document or application preferences
 		remap fonts no/ask -- remap document fonts which don't exist in the current system
 		do auto picture import yes/no/ask  -- whether or not to re-import any missing pictures
*)

I know this is pretty close to what I am looking to do but I get an error.
I made a folder1 and then made three subfolders and then in each one of the subfolders I placed a .qxd file. I took off the close document 1 in the code to see if the files would open one after another. But I got an error message at open thispath Quarkxpress can’t make some data into expected type.


set SourceFolder to (choose folder with prompt "") 
tell application "Finder" to set FolderList to get the name of every folder of SourceFolder 
repeat with thisFolder in FolderList 
   set thisSubFolder to (SourceFolder as string) & thisFolder as string 
   tell application "Finder" to set filelist to (get the name of every file of folder thisSubFolder whose file type = "XDOC") as list 
   repeat with thisFileName in filelist 
      set thisPath to (thisSubFolder as string) & ":" & thisFileName as string 
      tell application "QuarkXPress™" 
         --activate--(optional) 
         open thisPath   --GOT AN ERROR HERE

      end tell 
   end repeat 
end repeat 


It works for me - I have the following folder structure set up:

Main Folder–choose this when the script is run.
—>Sub Folder 1
----->File 1
----->File 2
----->File 3

—>Sub Folder 2
----->File 1
----->File 2
----->File 3

—>Sub Folder 3
----->File 1
----->File 2
----->File 3

When run, I choose the main folder. It then gets the name of every folder in the main folder and repeats with those names. On each subfolder it gets the names of only Quark files.

The error message you are getting leads me to believe that the script is concatenating a file path that doesn’t exist, so maybe you have your files and folders set up a different way?

You could toss up a dialog to display the path to the file you are opening

display dialog thisPath

just before the Quark open command. This way you can see where the path concat is going awry.

No my folders are setup just like yours. What version of Quark are you doing this with.
I am using Quark 5.01 and open thispath gets an error but I think I found the problem If I change that to Open file thispath it works.
I tried your code with Quark 4.11 and it works I don’t know why I have to make that change in 5.01 to make it work. Thanks for the help