How should I set path to /Library/Frameworks/SDL.framework
I did this:
set sourceFolder to (path to library folder)
set Sdl to (sourceFolder as string) & "Frameworks/SDL.framework" ----Wrong??? correct way???
tell application "Finder"
if exists folder Sdl then
delete folder Sdl
end if
end tell
You were real close. the 'path to' returns a : path, not a Posix path, so that slash in your definition of Sdl needs to be a colon :.
set sourceFolder to (path to library folder)
set Sdl to ((sourceFolder as string) & "Frameworks:SDL.framework")
tell application "Finder"
if exists folder Sdl then
delete folder Sdl
end if
end tell
Related
I need to modify my current code to allow for the selection of a a folder. My current code is as follows and works to select a folder without issue:
tell application "Finder"
set sourceFolder to folder POSIX file "/Users/Username/Desktop/Upload/Temp/HighRes/"
set theFiles to files of sourceFolder
set inputPath to "/Users/Username/Desktop/Upload/Temp/"
end tell
I have tried the following, but cannot determine the correct syntax to get to where I was in my original code
tell application "Finder"
set inputPath to folder POSIX file (choose folder with prompt "Please choose folder to be processed")
set sourceFolder to folder POSIX file (inputPath & "/HighRes")
set theFiles to files of sourceFolder
end tell
The above processes but errors out and says that finder got an error and cannot make alias "xyz" into type integer.
Please forget the POSIX dance. The Finder likes its native and alias specifiers.
tell application "Finder"
-- inputPath is an alias specifier
set inputPath to (choose folder with prompt "Please choose folder to be processed")
-- sourceFolder is built as a Finder item specifier
set sourceFolder to folder "HighRes" of inputPath
set theFiles to files of sourceFolder
end tell
Even your first snippet can be written in a simpler way
tell application "Finder"
set sourceFolder to folder "Upload:Temp:HighRes" of desktop
set theFiles to files of sourceFolder
set inputPath to folder "Upload:Temp" of desktop
end tell
I have a drive that has multiple "Approved" folders with files in them.
The Approved folders are in various locations on the drive.
I need to move the contents of the Approved folders to another directory via applescript.
This is what I have come up with so far but does not seem to be doing the trick, it runs but no files are moved...
Any tips would be great
Thanks
set sourceFolder to "THIS:" as alias
set destinationFolder to "THAT:" as alias
tell application "Finder"
repeat with aFolder in (get folders of sourceFolder)
set folderName to name of aFolder
set filesToMove to (files of sourceFolder whose name = "Approved")
move filesToMove to destinationFolder
end repeat
end tell
According to your description, you are looking for folders named Approved, but your script is searching for files named Approved. Try this:
set sourceFolder to choose folder
set destinationFolder to choose folder
tell application "Finder"
repeat with aFolder in (get folders of sourceFolder)
if aFolder's name is "Approved" then
set filesToMove to (files of aFolder)
move filesToMove to destinationFolder
end if
end repeat
end tell
I have the following applescript that takes files and puts them in their corresponding folders.
set sourceFolder to choose folder
tell application "Finder"
set theFiles to files of sourceFolder
repeat with aFile in theFiles
set fileName to name of aFile
if fileName contains "#" then
set poundOffset to offset of "#" in fileName
set folderName to text 1 thru (poundOffset - 2) of fileName
set newFolder to (sourceFolder as text) & folderName & ":"
if not (exists folder newFolder) then
make new folder at sourceFolder with properties {name:folderName}
end if
move aFile to folder newFolder
end if
end repeat
end tell
It works great for me except in the case of a file conflict. If there's a file with the same name in the folder that it's putting it in the script gets an error and crashes. So my question is this....How do I fix that? I'm willing for it to just overwrite the file but is there a way to bring up a prompt to skip the file or just skip it all together and move on to the next one?
I'm a little fuzzy on what I can do here. Thanks in advance for the help.
Ringslinger.
Try:
move aFile to folder newFolder replacing true
Hi, I'm trying to create an Applescript to do the following:
Over the week a have several jpg and eps files on my hard drive. I have two folders: Vector and Images.
After some few days I get a few dozens of this mixed files which I have to manually select and move to its respective folder.
How can I move the .eps to the VECTOR folder and the jpg to IMAGES folder.
I donĀ“t know anything about applescripting, so I copied parts of other scripts and put this together:
on run {input, parameters} -- copy
if theExtension is "eps" then
set destination to ~/user/Desktop/VECTO
end if
tell application "Finder"
move anItem to destination
if theExtension is "jpg" then
set destination to ~/user/Desktop/IMAGO
end if
tell application "Finder"
move anItem to destination
end run
Of course it is wrong, but wish someone could help me put this straight
Thnx!
I assume you are incorporating this into an Automator workflow from the way the question is phrased.
on run {input, parameters} -- copy
repeat with aFile in input
tell application "Finder"
if name extension of aFile is "eps" then
move aFile to folder ((path to desktop as text) & "VECTO")
else if name extension of aFile is "jpg" then
move aFile to folder ((path to desktop as text) & "IMAGO")
end if
end tell
end repeat
end run
If not you can use:
set myFiles to (choose file with multiple selections allowed)
repeat with aFile in myFiles
tell application "Finder"
if name extension of aFile is "eps" then
move aFile to folder ((path to desktop as text) & "VECTO")
else if name extension of aFile is "jpg" then
move aFile to folder ((path to desktop as text) & "IMAGO")
end if
end tell
end repeat
So I have this AppleScript for making aliases of all the contents of one folder to another folder.
I works perfectly unless there is only one item in the source folder.
tell application "Finder"
set SourceFolder to (choose folder with prompt "Please choose Source folder:") as string
set DestinationFolder to (choose folder with prompt "Choose Destination folder for aliases:") as string
set theFolders to every item of entire contents of folder SourceFolder
repeat with thisFolder in theFolders
set thisName to name of thisFolder
make new alias file at folder DestinationFolder to thisFolder without invisibles
end repeat
end tell
Any idea why it's not getting anything when there's one item only? When there's at least 2 items in the source folder it creates aliases for both in the destination.
On a side note, any way to get it to remember the source and destination folders between times you run it?
Try:
property SourceFolder : missing value
property DestinationFolder : missing value
if SourceFolder = missing value then
set SourceFolder to (choose folder with prompt "Please choose Source folder:")
set DestinationFolder to (choose folder with prompt "Choose Destination folder for aliases:")
else
tell application "Finder"
set theFolders to every item of entire contents of SourceFolder as list
repeat with thisFolder in theFolders
make new alias file at DestinationFolder to thisFolder
end repeat
end tell
end if