Re: How can I control invisible files
Re: How can I control invisible files
- Subject: Re: How can I control invisible files
- From: Robert Poland <email@hidden>
- Date: Sat, 03 Nov 2012 13:30:31 -0600
On Nov 3, 2012, at 12:38 PM, Doug McNutt < email@hidden> wrote: At 21:17 -0600 11/2/12, Robert Poland wrote:
Hi,
I like Doug's approach but I'm having trouble with the syntax.
tell application "Finder" set winTarget to target of front window as alias end tell
set fileList to list folder winTarget with invisibles
if fileList contains ".DS_Store" then set _file to quoted form of (POSIX path of (winTarget as text) & ".DS_Store") do shell script "sudo cp /dev/null _file" end if
It never ceases to amaze me that AppleScript can be so much more obtuse than perl or shell scripting.
sudo may need something like "with administrator privileges"
(winTarget as text) & ".DS_Store") might need a solidus depending on whether or not it's automatically included in the target request. (winTarget as text) & "/" & ".DS_Store"). Printing out the contents of _file would be good debugging.
Remember that do shell script requires full path names for everything. The new shell it brings each time has no knowledge of your current working directory. I do think you have that OK here but don't forget it.
And you also might need to draw some concentric red and black circles in the window to give the term "target" something to aim at. --
Applescript syntax is like English spelling: Roughly, though not thoroughly, thought through.
Thanks Doug,
I had forgotten that "do shell" needs the text formatted like "display dialog" does. In other words it needed the ampersand; like below
tell application "Finder" set winTarget to target of front window as alias end tell set fileList to list folder winTarget with invisibles if fileList contains ".DS_Store" then set _file to quoted form of (POSIX path of (winTarget as text) & ".DS_Store") do shell script "cp /dev/null " & _file end if
Robert Poland - Fort Collins, CO
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden