I have a current script to create a folder if it doesn’t already exist. I need to add a line to delete any files in said folder as well (if any already exist).
I have tried a couple times with examples from here and elsewhere, and I just keep screwing up the script completely, or having no change at all. Help please?
-- Create a hidden folder on the desktop. If it already exists, delete current contents.
set theOutputFolderPath to path to desktop folder
set theNewFolderName to ".hidden"
tell application "Finder"
if (exists folder (theOutputFolderPath & theNewFolderName as string)) = false then
make new folder at desktop with properties {name:theNewFolderName}
end if
end tell
set theOutputFolderPath to path to desktop folder
set theNewFolderName to ".hidden"
tell application "Finder"
if (exists folder (theOutputFolderPath & theNewFolderName as string)) = false then
try
make new folder at desktop with properties {name:theNewFolderName}
end try
end if
end tell
do shell script "rm -fr ~/Desktop/.hidden/*"
That’s an idea. The following seems to work with visible AND invisible “.”. I believe this step is solved. relevant portion (from larger script) shown below:
do shell script "rm -fr ~/Desktop/.hidden/"
set theOutputFolderPath to path to desktop folder
set theNewFolderName to ".hidden"
tell application "Finder"
if (exists folder (theOutputFolderPath & theNewFolderName as string)) = false then
make new folder at desktop with properties {name:theNewFolderName}
end if
end tell