Rename file to name of enclosing folder?

Hi gang,

I have approx 80 different folders and each need an Indesign file. I have created an Indesign Template that will be customized to text and images inside each folder.

I would like to be able to:

Chose the .indd template file
Select a folder
Duplicate the file into that folder
Rename the Indesign file with the first 30 letters of the enclosing folder (some of the folder names are really long).

I will eventually create an Indesign book so I can apply styles by syncing to my master document.

Tips anyone?

thanks!
cindy in indy

Hi,

you may try this code as droplet.
Drop your collection of folders on it. You will be asked for a file to copy.

Hope it’ll work as expected …



on open droppedFolders
	
	set theIndFile to choose file
	set theSuffix to name extension of (info for theIndFile)
	
	if theSuffix is missing value then
		set theSuffix to ""
	else
		set theSuffix to "." & theSuffix
	end if
	
	repeat with i from 1 to count of droppedFolders
		set aFolder to item i of droppedFolders
		set NewName to text 1 thru 30 of (name of (info for aFolder))
		
		do shell script "cp -f " & quoted form of POSIX path of theIndFile & space & quoted form of POSIX path of (((aFolder as text) & NewName & theSuffix) as text)
	end repeat
	
end open

Works great Hans!

Thanks for coming to the rescue … as I see you often do on this forum.

Have a great day!

cindy in indy