- Saving Files On Mac To Folders Onto
- Saving Files On Mac To Folders Mac
- Saving Files On Mac To Folders Backup
- My Files And Folders
Referencing Files and Folders in AppleScript
Start the Mac in safe mode once. Let me also describe how to start the mac in safe mode: Step 1: Turn off your mac. Step 2: Press and hold shift key and turn on the mac, hold the shift key till you see the apple logo. Identification of safe mode: In the upper right corner of the screen you will see the word 'safe mode' in red colour.
- Anybody that has both a Mac and a PC will understand that it's sometimes very convenient to setup shared folders that can be accessed from either machine, to save copying files to external media such as USB drives. There are several ways to share folders, and the process is actually quite simple.
- On the File menu, click Save, or press + S. Tip: Alternatively, you can click the Save icon in the upper left corner of the window. If you are saving the document for the first time, you must enter a file name.
- The same is the case from the command line. There are two commands for moving and copying: mv and cp.The first does the same as dragging a file to.
- Need a way to merge folders and treat files in the following manners: (1) If the two same-named files are the same, keep a copy of the file. (2) If the two same-names files are NOT the same, keep both copies. (3) If the file does NOT exist in the destination folder, move the file from source folder to destination folder. Is this possible?
In AppleScript, file and folder paths are typically represented using alias
, file
, and POSIX file
objects.
Note
Additional information about working with file and folder paths in AppleScript can be found in Aliases and Files in AppleScript Language Guide.
Alias Objects
An alias
object dynamically points to an existing item in the file system. Since an alias is dynamic, it continues pointing to the item even if the item is renamed or moved, the same way an alias file works when you manually create one in the Finder. With an AppleScript alias, the original item must exist at run time or an error will occur.
An alias
object is displayed as a colon-delimited path preceded by an alias
specifier, in the format shown in Listing 15-1.
APPLESCRIPT
Listing 15-1AppleScript: Structure of an alias objectalias 'VolumeName:FolderName:SubfolderName:FileName'
Listing 15-2 shows an example of an alias
object that references the Desktop folder.
APPLESCRIPT
Listing 15-2AppleScript: Example of an alias reference to a folderListing 15-3 is an example of an alias
object that references an existing file on the Desktop.
APPLESCRIPT
Listing 15-3AppleScript: Example of an alias reference to a filealias 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
To create an alias, add the alias specifier prefix to a colon-delimited path string, as shown in Listing 15-4.
APPLESCRIPT
Listing 15-4AppleScript: Creating an alias from a colon-delimited path stringset thePath to alias 'Macintosh HD:Users:yourUserName:Desktop:'
Many commands accept an alias as a parameter and/or return an alias as a result. In Listing 15-5, the choose file
command accepts a folder alias
object in its default location
parameter. The command then returns an alias
object that points to the chosen file.
APPLESCRIPT
Listing 15-5AppleScript: Example of a command that accepts an alias parameter and returns an alias resultset theDefaultFolder to alias 'Macintosh HD:Users:yourUserName:Desktop:'
choose file default location theDefaultFolder
--> Result: alias 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
File Objects
A file
object is a static reference to an item at a specific location in the file system. It's not dynamic, and can even refer to an item that doesn't exist yet. For example, a save
command may accept a file reference when saving to a new file.
A file
object is displayed as a colon-delimited path preceded by a file
specifier, in the format shown in Listing 15-6.
APPLESCRIPT
Listing 15-6AppleScript: Structure of a file objectfile 'VolumeName:FolderName:SubfolderName:FileName'
Listing 15-7 shows an example of a file
object that references a file that may or may not exist on the Desktop.
APPLESCRIPT
Listing 15-7AppleScript: Example of a file reference to a filefile 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
Unlike the way an alias
object works, you can't create a file
object simply by prefixing a path string with the file
specifier. For example, Listing 15-7 errors when run within a script.
APPLESCRIPT
Listing 15-8AppleScript: Example of incorrect usage of a file object specifierset theFile to file 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
Instead, you must prefix the path with the file
specifier at the time the file is targeted by a command, as shown in Listing 15-8.
APPLESCRIPT
Listing 15-9AppleScript: Example of correct usage of a file object specifierset theFile to 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
read file theFile
Note
A file
object can refer to either a file or a folder, despite the file
specifier prefix.
POSIX File Objects
Some scriptable apps are designed to work with POSIX-style paths, rather than AppleScript alias
and file
objects. Like a file
object, a POSIX file
object is not dynamic and can also refer to an item that doesn't exist yet.
A POSIX file
object is displayed as a slash-delimited path preceded by a POSIX file
specifier, in the format shown in Listing 15-10.
APPLESCRIPT
Listing 15-10AppleScript: Structure of a POSIX file objectListing 15-11 is an example of a POSIX file
object that references a file that may or may not exist on the Desktop.
APPLESCRIPT
Listing 15-11AppleScript: Example of a POSIX file reference to a filePOSIX file '/Users/yourUserName/Desktop/My File.txt'
Note
A POSIX file
object can refer to either a file or a folder, despite the POSIX file
specifier prefix.
In a POSIX path, the startup disk's name is omitted and represented by a leading slash. Other disks are referenced in relation to the Volumes
directory of the startup disk, for example: /Volumes/DiskName/FolderName/SubFolderName/FileName
.
App-Specific References to Files and Folders
Some apps, such as the Finder and System Events, have their own syntax for referring to files and folders. Listing 15-12 shows how a Finder file reference appears.
APPLESCRIPT
Listing 15-12AppleScript: Example of a reference to a file in the Finderdocument file 'My File.txt' of folder 'Desktop' of folder 'yourUserName' of folder 'Users' of startup disk of application 'Finder'
Listing 15-13 shows how a System Events folder reference appears.
APPLESCRIPT
Listing 15-13AppleScript: Example of a reference to a folder in System Eventsfolder 'Macintosh HD:Users:yourUserName:Desktop:' of application 'System Events'
Since this terminology is app-specific, it doesn't work in other apps. For example, you can't write a script that tries to import a Finder reference to an audio file into iTunes because iTunes doesn't understand Finder file references. In this case, you must coerce the Finder file reference to something iTunes can understand, like an alias. See Converting Between Path Formats below. In most cases, apps with their own path syntax also support standard AppleScript path types.
Converting Between Path Formats
Since different situations may result in paths appearing in different formats, you may need to regularly convert one path format to another. Sometimes, this can be done by using the as
coercion operator, as shown in Listing 15-14, Listing 15-15, Listing 15-16, and Listing 15-17.
APPLESCRIPT
Listing 15-14AppleScript: Coercing a string to an aliasset theFilePath to 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
set theFilePath to theFilePath as alias
--> Result: alias 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
APPLESCRIPT
Listing 15-15AppleScript: Coercing an alias to a stringset theFilePath to choose file
--> Result: alias 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
set theFilePath to theFilePath as string
--> Result: 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
APPLESCRIPT
Listing 15-16AppleScript: Coercing a POSIX file to an aliasset theFilePath to POSIX file '/Users/yourUserName/Desktop/My File.txt'
set theFilePath to theFilePath as alias
--> Result: alias 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
APPLESCRIPT
Listing 15-17AppleScript: Coercing a Finder file reference to an aliastell application 'Finder'
set theFilePath to file 'My File.txt' of desktop
end tell
--> Result: document file 'My File.txt' of folder 'Desktop' of folder 'yourUserName' of folder 'Users' of startup disk of application 'Finder'
set theFilePath to theFilePath as alias
--> Result: alias 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
Converting from a string or alias to a POSIX path can't be done through coercion. Instead, you must access the POSIX path
property of the path to convert, as shown in Listing 15-18.
APPLESCRIPT
Listing 15-18AppleScript: Converting an alias to a POSIX path stringset theFilePath to choose file
--> Result: alias 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
set theFilePath to POSIX path of theFilePath
--> Result: '/Users/yourUserName/Desktop/My File.txt'
Using Conversion Handlers
Running paths through a conversion handler is a good way to ensure the format you expect.
Converting a Path to an Aliases
The handler in Listing 15-19 converts strings, path
objects, POSIX file
objects, Finder paths, and System Events paths to alias
format.
Saving Files On Mac To Folders Onto
APPLESCRIPT
Listing 15-19AppleScript: Handler that converts a path to an AppleScript aliason convertPathToAlias(thePath)
tell application 'System Events'
try
return (path of disk item (thePath as string)) as alias
on error
return (path of disk item (path of thePath) as string) as alias
end try
end tell
end convertPathToAlias
Listing 15-19 shows how to call the handler in Listing 15-19 to convert a POSIX-style path string to an alias.
APPLESCRIPT
Listing 15-20AppleScript: Calling a handler to convert a path to an AppleScript aliasset thePath to '/Users/yourUserName/Desktop/My File.txt'
set thePath to convertPathToAlias(thePath)
--> Result: alias 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
Converting a Path to a String
The handler in Listing 15-21 converts a path to string format.
APPLESCRIPT
Listing 15-21AppleScript: Handler that converts a path to an a stringon convertPathToString(thePath)
tell application 'System Events'
try
return path of disk item (thePath as string)
on error
return path of thePath
end try
end tell
end convertPathToString
Listing 15-22 shows how to call the handler in Listing 15-21 to convert an alias to a path string.
APPLESCRIPT
Listing 15-22AppleScript: Calling a handler to convert an AppleScript alias to a path stringset thePath to alias 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
set thePath to convertPathToString(thePath)
--> Result: 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
Converting a Path to a POSIX Path String
The handler in Listing 15-23 converts a path to POSIX path string format.
APPLESCRIPT
Listing 15-23AppleScript: Handler that converts a path to an a POSIX path stringon convertPathToPOSIXString(thePath)
tell application 'System Events'
try
set thePath to path of disk item (thePath as string)
on error
set thePath to path of thePath
end try
end tell
return POSIX path of thePath
end convertPathToPOSIXString
Listing 15-24 shows how to call the handler in Listing 15-23 to convert an alias to a path string.
APPLESCRIPT
Listing 15-24AppleScript: Calling a handler to convert an AppleScript alias to a POSIX path stringset thePath to alias 'Macintosh HD:Users:yourUserName:Desktop:My File.txt'
set thePath to convertPathToPOSIXString(thePath)
--> Result: '/Users/yourUserName/Desktop/My File.txt'
Dec 21, 2020 • Filed to: Solve Mac Problems • Proven solutions
If you are relatively new to the macOS system, then chances are that you might encounter a similar situation as well. Although macOS is quite user-friendly, sometimes it can take a lot of time to find a file or locate a particular folder. Just like Windows or Linux, Mac also presents different ways to find files and browse its local storage system.
In this post, we will teach you how to find folders on Mac as well as recover any lost document on your Mac system as well.
Part 1. How to Find Hidden Files and Folders on Mac Hard Drive?
Usb mac os mojave. Ideally, you can browse the internal hard drive or Mac or even explore an external device well. The solution to find lost files on Mac would be the same for almost every major version. Though, there might be some change in the overall interface of the macOS. The following are some of the common techniques that you can follow to find any file on Mac.
1. Use Recent Items to Find Documents on Mac
If you wish to find some recently opened files or folders on Mac, then you can follow this simple approach. The macOS would maintain a record of the recently accessed documents, applications, and sometimes even system processes. Therefore, you can quickly learn how to find lost files on Mac with this approach.
- Just go to the Apple logo on the top left corner of the screen and click on the 'Recent Items' option.
- This will give you a list of the recently accessed folders, apps, and documents. Just click on the icon of your choice to view the file or application.
- Additionally, you can also go to the File menu > Open Recent section to view the recently accessed files. You can clear the history from here or click on any file to access it once again.
2. Check the Downloads Folder to Find Files
Too often, Mac users download something from the internet and later realize that the downloaded document disappeared on Mac. If you also think that the Mac download folder is missing, then consider following these quick steps.
- To start with, go to the desktop on your Mac system and visit the 'Go' section from the main menu. From here, you can visit the 'Downloads' folder on Mac.
- Alternatively, you can also go to your Library and click on the 'Downloads' section from the left panel.
- Once the Downloads folder on Mac has been opened, you can just look for any file of your choice. There is a search tab on the top that can help you do the same in less time. Simply click on it and type the name of the file you are looking for in the Downloads folder.
3. Check the Trash to Find Deleted Files
When we delete something on Mac, the file is not removed from the storage right away. On the contrary, it will be moved to the Trash, from where we can recover the deleted data if we want to. Therefore, if you can't find lost documents or folders on Mac, then make sure that you check its Trash before taking any drastic measures.
- Firstly, you need to access the Trash folder on Mac. You can do this by clicking on the Trash icon on the dock.
- When the Trash folder would be opened, you can view all the deleted files that are stored on it temporarily.
- If you wish to recover a file, then select it, and right-click. Click on the 'Put Back' option from the context menu to restore it to its original location.
4. Search the Spotlight to Find Files and Folders
Spotlight is probably one of the most resourceful features in macOS. Since Spotlight has been an evident feature in every major macOS, you won't face the slightest of trouble in finding any file on your Mac system. The feature can be accessed from the desktop and will let you look for files, documents, internet searches, and so much more in one place. If you don't know where to find documents on Mac, then simply follow this drill.
- To access Spotlight, go to your Mac's desktop and click on the search icon on the top right corner of the screen. Here, type the name of any file or folder that you are looking for.
- In no time, the system will start looking for suitable content with respect to the searched keyword. Once you get the results, you can just hover the mouse on the icon to get its preview. Ideally, Mac will let you preview pictures, videos, audios, documents, etc.
- In order to access a file, simply click on it and it will be opened on your Mac system. If you want, you can click on the 'Show All in Finder' option as well to view all the searched results together.
- This will display the relevant results in Finder so that you can find the suitable files and folders that you were looking for.
5. Use Terminal to Find Files and Folders on Mac
The terminal is one of the most useful utility tools in Mac that lets us send direct commands to our system. A lot of users are not able to find any file or folder on Mac which is hidden. In this case, you can take the assistance of Terminal to view the hidden files/folders first. Later, you can go to Finder on Mac to access the data of your choice.
- To begin with, you need to launch the Terminal app. Go to Applications > Utilities and open the Terminal app or look for it from the Spotlight.
- 2. Once Terminal is launched on your Mac, simply copy the following commands and press enter: defaults write com.apple.finder AppleShowAllFiles TRUE killall Finder
- This will restart Finder and will display all the hidden files and folders on it as well. Now, you can just click on the search icon and enter the name of the files/folder you are looking for. This will let you find files and folders on Mac that are even hidden from the user.
If the content you are looking for is present on your Mac's storage, then you would be able to find it by following the above-listed methods. These techniques will work even if the data has been hidden or deleted so that you can find any file on Mac seamlessly. Though, if your data is deleted or inaccessible, then consider following the next section to find lost files on Mac.
Part 2. How to Find Lost Files on Mac?
Microsoft office on mac catalina. There are times when users end up losing their important data on Mac. While there could be different reasons behind it, you can easily find lost documents on Mac by using the right methods.
Why Files Get Lost?
Saving Files On Mac To Folders Mac
Before we teach you how to find lost documents on Mac, it is important to know what could have caused the situation in the first place. Here are some of the major reasons for data loss on Mac.
- Sometimes, users end up deleting something accidentally, which gets lost.
- The change in location of the files can make them inaccessible at times.
- A virus or malware attack on the storage can make your files corrupt.
- Chances are that your data could be overwritten by something else.
- The data can be mishandled by a third-party application as well.
- The storage unit or partition can get corrupt or formatted.
- A firmware issue, corrupt update, or any other software-related problem
Part 2. How to Find Lost Files on Mac?
Microsoft office on mac catalina. There are times when users end up losing their important data on Mac. While there could be different reasons behind it, you can easily find lost documents on Mac by using the right methods.
Why Files Get Lost?
Saving Files On Mac To Folders Mac
Before we teach you how to find lost documents on Mac, it is important to know what could have caused the situation in the first place. Here are some of the major reasons for data loss on Mac.
- Sometimes, users end up deleting something accidentally, which gets lost.
- The change in location of the files can make them inaccessible at times.
- A virus or malware attack on the storage can make your files corrupt.
- Chances are that your data could be overwritten by something else.
- The data can be mishandled by a third-party application as well.
- The storage unit or partition can get corrupt or formatted.
- A firmware issue, corrupt update, or any other software-related problem
Recoverit Data Recovery: The Best Mac Lost Partition Recovery Software
No matter what could have caused your files to be lost on inaccessible, you can easily get them back using Recoverit Mac Data Recovery software. It is an extremely reliable and advanced data recovery tool that supports every leading Mac and Windows version. The application is developed by Wondershare and yields positive results in all kinds of data loss scenarios. Also, it is extremely easy to use and will not need any prior technical experience to find lost files on Mac through it.
If you have deleted a partition on Mac or have lost it due to any other reason, then you should use Recoverit Data Recovery. It can help you restore partition data on Mac by following these easy steps.
Step 1: Select a disk
To start with, just launch the Recoverit Data Recovery application on your Mac. Subsequently, the application will identify the inbuilt partitions on your Mac and will provide their list. You can just select a partition of your choice and start the recovery process.
Step 2: Scan the Location
In no time, Recoverit would try to access the lost content from the selected partition. Though, if the partition has been lost, then the quick scan might not yield the needed results. In this case, you can perform a Deep Scan on your Mac to scan the entire storage.
Since it might take a while, it is recommended to wait for the recovery process to be completed. Try not to restart your Mac or close the application when it is performing a deep scan.
Step 3: Preview and Recover
Saving Files On Mac To Folders Backup
That's it! Once the process is complete, the application will display the recovered data under various categories. You can view a section from the left panel and preview your data on the right.
In the end, you can select the files you wish to get back and click on the 'Recover' button to save them to a secure location.
In some new macOS versions, third-party applications are not allowed to access the logical partition of the drive. To overcome this, you can reboot Mac in recovery mode and launch Terminal from the utility menu. Type 'csrutil disable' and press enter to disable its System Integrity Protection. Once it is done, restart Mac in the normal mode and run Recoverit Data Recovery again.
Part 3. Tips for Finding Files on Mac
If you don't want to lose your data and learn how to find files on Mac quickly, then consider following these expert suggestions:
- There are all kinds of keyboard shortcuts that you can use while browsing the file system on Mac. For instance, if you have been browsing a directory and would like to go back to the default folder, then press the Command + Shift + H keys. This will take you back to the home instantly.
- Finder in Mac also allows us to set some default folders so that we can access them easily. Just go to the Finder Preferences to set a default folder for quick access.
- The toolbar on Mac already provides a lot of options, but you can further customize it to make it easier for you to find files on Mac. Just go to View > Customize Toolbar and make the needed adjustments.
- You can easily look for a file through the 'Search' bar on Finder. Also, you can sort the displayed data on the basis of different parameters (like size, last modified, etc.) to find files easily.
- Mac also lets us preview files before opening them in order to find the respective content. For instance, you can just select a file and click on the Quick Look button to get its preview in seconds.
There you go! After reading this guide, you would be able to find any file on Mac without much trouble. We have listed different inbuilt methods to find lost documents on Mac, recover hidden files, and even restore deleted data. If you can't find lost files on Mac via Trash, then consider using Recoverit Data Recovery. It is an advanced and user-friendly data recovery application that will help you get back all kinds of content lost on your Mac. Since the tool is available for free (basic version), you can simply download it on your Mac and use it as per your requirements.
What's Wrong with Mac
My Files And Folders
- Recover Your Mac
- Fix Your Mac
- Delete Your Mac
- Learn Mac Hacks