Applescript: set folder as current folder - applescript

I'm trying to move a file to the current folder in Finder, with Applescript. The end result would be being in a specific folder in the Finder, hitting a shortcut on the keyboard, and having the file moved from the Downloads folder to the current folder.
I'm struggling to find a way to refer to the current folder, and to test this out in Applescript. Does anyone have any idea on the subject?
Thanks in advance!

The Finder has no notion of a "current folder". The folder that the user might be said to be "in" is the folder represented by the Finder's first window. You can experiment by saying:
tell application "Finder"
activate
try
get folder of window 1
end try
end tell

Related

Could not rename “New Group” to “ My Group”. in Xcode10.2

I just created a group and want to rename it but getting unable to update popup.
I know how to rename it from show in finder. but y Apple in Xcode 10.2 does not allowed it directly from Xcode?
Or
Am i missing something?
I was facing the same issue today. Only thing which helped me was quitting the Xcode and restarting it. It is working for me now
I just checked and found another way without restarting Xcode.
I have the same issue. #ravin001 i did the same thing as you and quit and restarted Xcode but i found another way.
• Go ahead and Right Click wherever you want to create the Folder/Group.
• Select New Group.
• Press Enter to name the Folder/Group whatever Xcode suggested (usually "New Group").
• Now make sure the new Folder/Group is selected and Open the inspector panel.
Inspector Panel: top most right corner.
• The little page "file inspector" should be highlighted. If not, select it.
Trying to rename it won't work, First you have to rename the folder wherever it's stored.
- To do so:
• In the inspector panel, underneath the "location" title, you should see a folder icon. Click on that folder icon.
• Xcode will open a "choose a location" folder structure widget right in the middle of the screen.
• Right Click on the "New Group" folder and Rename it to whatever you want.
• Click on the 'Choose' button to close the widget ("It's important to select choose")
Now you rename the folder to whatever you like in Xcode
NOTE
• Renaming the folder any other way other than through the "Choose a location" way, won't work and you still won't be able to edit the folder
• You'll need to do this for every folder you create. So if you just created the project and will be adding a lot of folders, then it's probably best to restart xcode
I was seeing this problem today. After further investigation I determined it was due to already having folders in that directory using the same names. This was caused by creating a Group in Xcode but reverting my git changes, which didn't revert the folder creation only the Xcode Project File changes.
Check in Finder that the folder/group names are unique.
If you just created this group and you know for sure that the name wasn't already used in this project... Make sure the folder is not open.
You do this but looking to the left side of the folder(there is a triangle/arrow) if the triangle is pointing down, this means the folder is open and Xcode won't allow you to rename the folder.
Simply press the triangle to close it (it will be pointing towards the right when closed) and try to rename again.
You shouldn't have to exit out of Xcode!!!
See next to "New Group" the arrow is pointing down
Tap on the arrow and it will point to the right
Now you are able to change the name to Controller
Let me know if this solved you issue.
i am also facing this issue. What works for me is Force Quit Xcode and restart it. Also make sure that your group should be in Right path by Right Clicking and show in Finder option.
In my case the folder was already created on the filesystem but it wasn't showing on the Project Navigator.
I only had to change the location of the "New Group" folder using the folder icon on File Inspector tab.
I think its not related to xcode, its finder problem, because directory still exists and finder doesn't show that, you can see directory exists by entering ls in terminal.
How to solve this?
Open terminal and navigate to parent directory of desired directory : cd ~/../parent or just right click parent directory and choose New Terminal at Folder
Remove desired directory : rm -rf MyGroup
Now you can try to create your group with MyGroup name.
Ok... When you create a group it also creates a folder there. If you delete the group, the folder will not be deleted. Then if you change your mind and create the group again, it will try to create the folder again. But since the folder exists, the OS will throw an error which Xcode just reports as an inability to create the group.
So just rename or delete the underlying folder and now you can rename the group. You can rearrange the files in Finder after that.
First Restart Xcode. If restart doesn't work then check that is same group name already exist inside folder. If group exist then delete it. Hope this two process will help to solve this issue.

Mac Textedit link to folder

Is there a way to create a link to a folder in a Textedit document?
Textedit native interface clearly cannot link to a folder. Finder, drag folder or alias to textedit document, then directly or through system prompts an image icon is created in the Textedit document to represent the folder (or file), but no link is created.
I came here looking for a way to open another TextEdit file using a hotlink. The previous ideas are definitely a step forward for me. While this is a slightly different question, my results may be useful here.
Using the file:// prefix on a full file path of the form:
file:///Users/myname/Documents/Personal/.../file.rtf
If the file is not already open, then the hotlink opens Finder and the file is highlighted.
If the file is already open, then the link takes me to the open file.
I have not found a way to get it to open a file that is not already open.
Results are a little differet when the link is to a folder instead of a file. Using the file:// prefix on a full folder path of the form:
file:///Users/myname/Documents/Personal/.../foldername/
Whether or not the named folder is already open, the hotlink opens Finder for the parent folder and the named folder is highlighted.
If the parent folder is already open, then the link goes to that open folder and highlights the named folder.
I have not found a way to get it to open the target folder, other than by naming a file that is in that folder. The special name "." does not work for that.
In Mojave 10.14.6, using hotlinks to other RTF files that open in TextEdit by default.
Here is a very time-consuming, but effective method to link to a folder from a Textedit document.
Add a file to folder (e.g., an image file), select the file;
Context menu 'Open with...' and select browser (Safari);
Edit browser address bar path to delete filename, leaving path to folder, and copy this address to clipboard;
In Textedit document, enter some text to link to folder (e.g., folder name);
Select text, press Command-K and paste folder path, save.
Now you have a Textedit link to the folder that will open in Finder! Maybe... using Automator and System Preferences Keyboard, this could be turned into a context menu command. Though I am noticing that in macOS Sierra 10.12.1 the use of customizations for context commands is flakey, TO PUT IT MILDLY... There has to be an easier way!
macOS Sierra version 10.12.1
I couldn't get Chrome nor Safari to allow me to select a file path. This is an updated version of Mark Stewart's response that worked for me.
Right click and select "get info" on the file you want to link to in the text document. (You can also select the file and hit "Command + i" to bring up the info dialog box)
Right click the file path in the "Where" field under the "General Section" and select copy
Go to the TextEdit document that you want to create the link in
Select the text you want to use as a link
Select text, press Command-K and paste folder path, but don't hit save yet.
Add the text "file:" without the quotes to the beginning of the link
Add a "/" character (not including the quotes) and the filename and the extension to the end of the link.
Now hit ok or save
I am sure someone could create a hot folder or right click menu that would build the path and precede it with file: and save it to the clipboard automatically.
macOS Catalina 10.15
The Open service should work for opening files and folders from paths in TextEdit and other text editors.
Two ways of getting a file or folder path into TextEdit:
For plain text documents: Simply drag'n'drop a file from Finder to your TextEdit document or
For RTF formatted documents: Select the file or folder in Finder, copy the file path (Command + Option + C), select your document in TextEdit, paste the path to the document (Command + V). That avoids the icon and pastes a text link to formatted and unformatted TextEdit documents.
The result will be something like this: /Path/To/File.ext for files or /Path/To/Folder for folders
To open a file or folder path from TextEdit with the Open service
Select the whole path in TextEdit (e.g. by left-click + hold + move or by moving the cursor with the help of the Arrow keys to the beginning or the end of the path, then select the path by pressing Shift + Arrow left/right keys, optionally in combination with Command or Option key)
Select the service Open from the Service Menu (Contextual or TextEdit menu).
Confirm the dialog Confirm Service: TextEdit wants to use the restricted Service “Open.” by pressing Run Service
You might also want to setup a keyboard shortcut for utilizing the Service Open (e.g. Command + Shift + O). It can be done in  > System Preferences > Keyboard > Shortcuts > Services > Text > Open. In the same Keyboard setting window tab, you can also activate All controls for dialog boxes, so that you can confirm Run Service by pressing Spacebar to get keyboard control for the whole task.
Automator:
workflow receives current 'files or folders' in 'Finder'.
Utilities:
'Copy to Clipboard'. Then
save service as:
'Copy Path'.
Finder: right click object (folder or file) and select service Copy Path.
TextEdit: edit link, type file: and paste path from clipboard.

Auto-updating images folder in Xcode

Is there some a better way to import images to Xcode than dragging them into project/group/subgroup etc... Not mentioning the creating of retina & non-retina version - I know there are scripts for that, but if there was a way to faster this routine it would be great!
The best way that comes to my mind is that I just copy the into proper folder and it appears in the project in associated group in both retina & non-retina versions.
Folder Actions is another option? i.e. right click on a folder i.e. the folder you save the images to from whichever is your favourite editor, click on "Services" then on "Folder Action Setup" and set up an automator workflow to do this.
Set up a simple "move file from..to" workflow i.e. from the folder you save images to, to the folder you have set up as a group in Xcode.

How to move all images into one group in xcode

All images and header files are looking very confusing. So i want to separate all images and other files into different groups. Anyone please help me
To organize your files on disk, simply make the folders you want to make in the Finder and drag the files to them. To do this, open the folder containing your .xcodeproj file in the Finder. Use Cmd-Shift-N to create a new folder or choose "New Folder" from the "File" menu. You'll be prompted to give the folder a name. You'll probably want to name it something like "Images" or "Headers". Once the folder is created, you can simply click on an image file and drag it to the "Images" folder (or whatever you named it). Repeat the process for any files you want to move.
Once you've done the above, the files may display as red in Xcode's Project Navigator. If that's the case, you need to select the file in Xcode's Project Navigator and show the "Utilities" pane (the right-most button in the toolbar opens and closes the Utilities pane). There are 2 tabs in the Utilities pane - the File Inspector and Quick Help. Click on the File Inspector. It should display the name of your file, the type, and the location. Next to the "Location" is an icon of a folder. Click on the folder and you'll be presented with a file navigation dialog. Navigate to the new location of the file and select it. Click the "Choose" button and the file will be re-connected in Xcode.
You may need to repeat the process for any files you moved into new folders.
In Xcode you can also use 'groups'. A kind of virtual directory structure.
Iu the left xcode column (the Navigator), right click and select 'group'

Access file name in Automator from Folder Action

I'm trying to create a simple Automator workflow that will prompt me for where to move and rename a PDF when I download one from the web. I want to use this for downloading my monthly financial statements.
I'm getting stuck at what I thought would be a simple problem: passing the name of the new file(s) from the Folder Action into the Automator workflow.
How is this done? I tried the "Get Specified Finder Items" action, disabling its input, and passed that to "Set Value of Variable" and in turn to "Ask for Conformation" so I could display the name of the file. It seems whatever I try, I cannot find how to pass the name of the newly downloaded files to the Automator workflow.
This seems like it should be simple. Does someone have an example of an Automator workflow triggered by a Folder Action that passes the files into the workflow?
For the life of me, I can never understand Automator. However I believe I can help in this case. The action you are looking for is called "Get Selected Finder Items" -- it is not intuitive, blame Apple for that.
To test out, I created a folder called "automator_action", then I started Automator (in Snow Leopard) and chose "Folder Action". This is the step you will need to figure out if you are using Leopard or earlier OS.
Next, I drag the "Get Selected Finder Items" (under Finder) over to the right pane, then I dragged the "Rename Finder Items" over and customized it. Finally, I saved the action and ready to test it out. You can see the picture presentation of my "script" here:
http://farm3.static.flickr.com/2590/3937364947_33b1a3ab45_o.png
I tested out the action by dragging a file into this folder and sure enough, the action renames it the way I intended. Dragging multiple files also works. Good luck.

Resources