The error is with "desktop:_XNB_Extract:"
tell application "Finder"
set x to path to desktop
make new folder at x with properties {name:"_XNB_Extract"}
set y to path to "desktop:_XNB_Extract:"
make new folder at y with properties {name:"Packed"}
end tell
Easy vanilla AppleScript solution:
tell application "Finder"
set extractFolder to make new folder at desktop with properties {name:"_XNB_Extract"}
make new folder at extractFolder with properties {name:"Packed"}
end tell
You can even omit at desktop because the desktop folder is the root folder of the Finder.
Related
I have the below code, which works to copy the contents of Downloads to the desktop. What I would like to do is copy it to the newly created folder, the folder_name, which is the current date and time.
set folder_name to (current date)
set folder_name to folder_name as string
tell application "Finder"
set p to path to desktop
make new folder at p with properties {name:folder_name}
end tell
tell application "Finder"
move (files of alias "Macintosh HD:Users:XXXXX:Downloads") to desktop
end tell
Essentially, I'm not sure how to pass folder_name into the final path. I tried (desktop & folder_name)
Thanks
The make new folder command of the Finder returns the new folder.
And there is a relative path to the Downloads folder of the current user
set currentDate to (current date) as string
set downloadsFolder to path to downloads folder
tell application "Finder"
set currentFolder to make new folder at desktop with properties {name: currentDate}
move (files of downloadsFolder) to currentFolder
end tell
I'm trying to open iCloud in the current Finder window/tab. The below AppleScript works with any other folder.
How can I open iCloud in the current Finder window with AppleScript?
tell application "Finder"
reopen
activate
set p to "~/Library/Mobile Documents/"
set target of Finder window 1 to POSIX file p
end tell
The script doesn't work because the Finder is not able to expand the tilde in POSIX paths.
This is an alternative with a relative path.
set userLibraryFolder to path to library folder from user domain
tell application "Finder"
reopen
activate
set iCloudDriveFolder to folder "iCloud Drive" of folder "Mobile Documents" of userLibraryFolder
set target of Finder window 1 to iCloudDriveFolder
end tell
This isn't a complete answer because this won't open the iCloud folder in the current tab, but it does open the iCloud folder rather than the "Mobile Documents" folder:
tell application "System Events" to open folder "~/Library/Mobile Documents"
I'm not familiar with any method that will give you the best of both worlds. It seems that you either must settle for the "Mobile Documents" folder opening in the tab you want; or a new tab being created to open the folder you want.
This is easy.
Create an alias of the iCloud folder and place that on the local hard drive then use Apple Script to open the alias and that opens the iCloud folder:
set itemPath to "Macintosh HD:Users:username:folder:alias_name"
tell application "Finder"
set theItem to item itemPath
if (class of theItem) is folder then activate
open theItem
end tell
I'm trying to copy all files from a folder to another.
This works only if I specify the full path including the name of the drive and the username.
This works:
tell application "Finder"
set a to folder "Macintosh HD:Users:Michael:Desktop:Files:"
set b to folder "Macintosh HD:Users:Michael:Desktop:Copies"
duplicate every file of a to b
end tell
But I want to have this compatible with any HDD naming and username.
So I'm looking for a relative path, equivalent to ~:Desktop.
The relative path equivalent is
set desktopFolder to path to desktop
tell application "Finder"
set a to folder "Files:" of desktopFolder
set b to folder "Copies:" of desktopFolder
duplicate every file of a to b
end tell
But the Finder has a property desktop which points always to the desktop folder of the current user.
tell application "Finder"
set a to folder "Files:" of desktop
set b to folder "Copies:" of desktop
duplicate every file of a to b
end tell
And – even shorter – the desktop folder of the current user is the "root" folder of the Finder
tell application "Finder"
duplicate every file of folder "Files" to folder "Copies"
end tell
Edit:
The equivalent to
~/Library/Containers/com.apple.iWork.Numbers/Data/Library/Application Support/User Templates
is
((path to library folder from user domain as text) & "Containers:com.apple.iWork.Numbers:Data:Library:Application Support:User Templates:")
I'm trying to launch a Finder window of a folder that's in the same directory as my script. When I run the code below, it launches a blank Finder window set to the path of the script not to the folder.
tell application "Finder"
tell application "Finder" to make new Finder window
set file_path to (path to me) as text
set target of Finder window 1 to file_path
end tell
How can I get the path to the folder of the script, not the script?
You were close. You do not need the text version of the file, you only need the file itself, then you can ask Finder for that file's container:
tell application "Finder"
tell application "Finder" to make new Finder window
set file_path to (path to me)
set target of Finder window 1 to file_path's container
end tell
The shortest way I know to do this is:
tell application "Finder" to open ((path to me as text) & "::")
Editing your script renders the following:
tell application "Finder"
make new Finder window -- There is no need for an your second tell statement
set file_path to (path to me as text) & "::" -- Goes up one directory
set target of Finder window 1 to file_path
end tell
Filemaker has the ability to ake use of AppleScript.
From within Filemaker I want to create a new folder (with the name of a FileMaker field) that holds 6 subfolders.
I am a complete noob where it comes to Applescript.
This is my script so far:
tell application "FileMaker Pro Advanced"
set folder_name to cell "FolderName" of current record
end tell
tell application "Finder"
activate
make new folder at folder "Desktop" of folder "dick" of folder "Users" of startup disk with properties {name:folder_name}
end tell
tell application "Finder"
activate
make new folder at folder {name:folder_name} of folder "Desktop" of folder "dick" of folder "Users" of startup disk with properties {name:"subfolder"}
end tell
My problem is: the creation of "Subfolder1"
What is my mistake there?
Help is much appreciated
When you crate a new folder you can define various properties, but when refering to the folder just use the name, for example:
make new folder at folder folder_name of folder "Desktop" of folder "dick" of folder "Users" of startup disk with properties {name:"subfolder"}
Note that the result returned from making a new folder is a reference to that folder, so you can also do something like:
tell application "Finder"
set newFolder to (make new folder at folder "Desktop" of folder "dick" of folder "Users" of startup disk with properties {name:folder_name})
make new folder at newFolder with properties {name:"subfolder"}
end tell
Here is another approach:
set myPath to POSIX path of ((path to desktop as text) & folder_name & ":subfolder")
do shell script "mkdir -p " & myPath