Hidden folder/files

Impossible to do this with hidden folder?


tell application "Finder"
	set folderFiles to files of folder POSIX file "~/.hiddenfolder" as alias list
end tell

Thank you, thank you :slight_smile:

The following will do what you want but only if the Finder is set to show hiden files, which normally would not be the case.

set theFolder to ((path to home folder as text) & ".hiddenfolder")

tell application "Finder"
	set theFiles to files in folder theFolder as alias list
end tell

System Events will do what you want regardless of Finder’s hidden-file setting.

set theFolder to ((path to home folder as text) & ".hiddenfolder")

tell application "System Events"
	set theFiles to files in folder theFolder
end tell

repeat with aFile in theFiles
	set contents of aFile to aFile as alias
end repeat

If your script is working with POSIX paths, then the following can be used:

set theFolder to ((path to home folder as text) & ".hiddenfolder")

tell application "System Events"
	set theFiles to POSIX path of (files in folder theFolder)
end tell

A few comments:

  • The tilde shortcut can be made to work in an AppleScript but it’s generally best to use the path-to command instead.

  • Because the path-to command is part of Standard Additions, it’s generally recommended that it be kept outside tell statements. Similarly, POSIX file normally will not work inside a Finder tell statement.

  • System Events does not support “as alias list” and that’s the reason for the repeat loop in the second script.

This worked perfectly and thank you so much for the clarifying comments, I’m taking notes!