Skip to main content
BEGINNER_X
Legend
August 26, 2020
Answered

AppleScript - Folders and SubFolders --> INDD Count and Name

  • August 26, 2020
  • 2 replies
  • 2091 views

Dear All,

 

My request is, user has to select the Main Folder, but the script loop via sub folders and get the InDD file name, count etc..

 

So far, I got the script for the Main Folder InDesign Count only.

 

Any help is very appreciable..

 

tell application "Finder"
	set theList to files of folder (choose folder) whose name extension is in {"indd", "INDD", "idml", "IDML"}
	length of theList
end tell

 

 

 

This topic has been closed for replies.
Correct answer rob day

Try this:

 

 

set mainFolder to choose folder "Select a Main folder"


tell application "Finder"
	set listOfFolder to (every folder of entire contents of folder mainFolder) whose name is not "ABCD"
	
	set theList to {}
	repeat with i in listOfFolder
		set theInddList to ((every file of i) whose name extension is in {"indd", "INDD"})
		repeat with x in theInddList
			copy x as alias to the end of theList
		end repeat
	end repeat
	
	get theList
	--{alias "Fishercat OSX:Users:fishercat:Desktop:TEST:FOLDER A:IDFILEA.indd", alias "Fishercat OSX:Users:fishercat:Desktop:TEST:FOLDER B:IDFILEC.indd", alias "Fishercat OSX:Users:fishercat:Desktop:TEST:FOLDER B:IDFILED.indd", alias "Fishercat OSX:Users:fishercat:Desktop:TEST:FOLDER A:FOLDER C:IDFILEB.indd"}
end tell

 

 

 

2 replies

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
September 17, 2020

Try this:

 

 

set mainFolder to choose folder "Select a Main folder"


tell application "Finder"
	set listOfFolder to (every folder of entire contents of folder mainFolder) whose name is not "ABCD"
	
	set theList to {}
	repeat with i in listOfFolder
		set theInddList to ((every file of i) whose name extension is in {"indd", "INDD"})
		repeat with x in theInddList
			copy x as alias to the end of theList
		end repeat
	end repeat
	
	get theList
	--{alias "Fishercat OSX:Users:fishercat:Desktop:TEST:FOLDER A:IDFILEA.indd", alias "Fishercat OSX:Users:fishercat:Desktop:TEST:FOLDER B:IDFILEC.indd", alias "Fishercat OSX:Users:fishercat:Desktop:TEST:FOLDER B:IDFILED.indd", alias "Fishercat OSX:Users:fishercat:Desktop:TEST:FOLDER A:FOLDER C:IDFILEB.indd"}
end tell

 

 

 

BEGINNER_X
Legend
September 18, 2020

Hi Rob,

 

Thank you so much for your timely help...

 

You are my AppleScript Heroooo!! Works like a charm.

 

I will try the remaining part of the Automation by using your code.

 

Again Thanks a lot!

 

SS

rob day
Community Expert
Community Expert
August 26, 2020

Try this:

 

tell application "Finder"
	set the theFolder to (choose folder with prompt "Choose a folder.")
	set theList to (every file of entire contents of folder theFolder) whose name extension is in {"indd", "INDD", "idml"}
	get length of theList
end tell

 

 

You might need a timeout line, the user could choose a folder with 1000s of sub folders and files

BEGINNER_X
Legend
September 2, 2020

Hi Rob,

 

Sorry for the delayed response.. I will check and get back to you...

 

Thanks in Advance..

 

 

 

BEGINNER_X
Legend
September 17, 2020

Hi Rob/All,

 

Sorry for the very delayed response.. I was moved to some other urgent request.

 

Thats why, I'm not able to response for your reply..

 

I tested your code, it's working like a charm.

 

-------------------------------------------------------------------------

But our user modified the request slightly...

 

My new request is,

 

1. User has to select the Main Folder,

2. Script loop via all folders includes sub folder and get the InDD file name and Count 

3. But excludes or skip the INDD files in the folder name of "ABCD" (except this folder, we need the count)

 

Below code is developed so far, but I am not acheived my request.

 

 

set mainFolder to choose folder "Select a Main folder"


tell application "Finder"
	set listOfFolder to every folder of mainFolder
	display dialog (count of listOfFolder)
end tell


set theList to {}

repeat with i in listOfFolder
	set temp to the name of i
	
	if temp does not contain "ABCD" then
		set theArray to theList & temp
		--set theInddList to (every file of entire contents of folder listOfFolder) whose name extension is in {"indd", "INDD"}   --Error Found Here
	end if
end repeat