Fix type and creator of files recursively

I want to set the file and creator for all the files in the folder TEMP and all it’s sub-folders. I keep getting an error “Can’t set «class fcrt» of “U” to “CER3”.” Even if i get past this error, I’m sure this will do what I need it to. HELP!!! :mad:

property fileType : "DIAT"
property creatorType : "CER3"
set MyPath to "Users:shaun:Downloads:TEMP:"

tell application "Finder"
	activate
	set theseFolderItems to every item in MyPath
	repeat with theItem in theseFolderItems
		set the creator type of theItem to creatorType
		set file type of theItem to fileType
	end repeat
end tell

Hi,

I think you are looking for entire contents of and files of. Try:

property fileType : "DIAT"
property creatorType : "CER3"
set MyPath to "Users:shaun:Downloads:TEMP:"

tell application "Finder"
	activate
	set theseFolderItems to files of (entire contents of MyPath)
	repeat with theItem in theseFolderItems
		set the creator type of theItem to creatorType
		set file type of theItem to fileType
	end repeat
end tell

Your original script was trying to set the file type and creator code of the folders in the TEMP folder, which isn’t a property of folders (or containers), that is why you were getting errors. Take a look at Containers & Folders in the Finder’s Applescript dictionary.

Best wishes

John M

:frowning: I get the following error: Can’t get entire contents of “Users:shaun:Downloads:TEMP:”.

I don’t want this to be a droplet because I am going to run this on deployed machines that are experiencing this issue.

The folder TEMP contains no files and three folders. The files are inside these folders(1,2,3). Their structure is as follows:

Users
|
shaun
|
Downloads
|
TEMP
|
/—|—
1 2 3

Hi,

I tried this with a choose folder dialog instead of your path text. Try this:

property fileType : "DIAT"
property creatorType : "CER3"
set MyPath to "Users:shaun:Downloads:TEMP:"

tell application "Finder"
   activate
   set theseFolderItems to files of (entire contents of folder MyPath)
   repeat with theItem in theseFolderItems
       set the creator type of theItem to creatorType
       set file type of theItem to fileType
   end repeat
end tell

John M

Example:

tell application "Finder"
	tell every file of entire contents of folder "Downloads:TEMP:" of home
		set creator type to "CER3"
		set file type to "DIAT"
	end tell
end tell

If you must use HFS path strings, remember that unlike POSIX paths they must start with a disk name.