How-tos

How to Remove or Add ‘Where from’ Metadata in Files on macOS « Mac OS Tips :: Gadget Hacks



When you download files from certain apps like Safari and Chrome on your Mac, those files are tagged with the “Where from” metadata attribute. Depending on where the file was downloaded from, this attribute may refer to the host’s URL, a sender’s email address, or another piece of identifying information. While not obvious, you can delete or even change this attribute.

To see if a file on your Mac has the “Where from” attribute, select it in Finder, then either use the Command-I keyboard shortcut to open the info pane or right-click or Control-click it and select “Get Info.” If you don’t see a “Where from” tag in the More Info section, none was saved to the file. If you do see it, it may be the URL for the file’s location online, whether a simple website URL or a long, ugly attachment URL from services like Gmail and Google Drive. It’s up to the app’s developer to incorporate and customize the global kMDItemWhereFroms variable.

If you plan on sharing a photo, video, document, or other file type, you may not want the recipient to know where you got it from. Or, in the case of those long, ugly attachment URLs from services like Gmail and Google Drive, you may want to change the source link to something you or your recipients can reference since the auto-created embedded link will be annoying or useless.

Some apps will wipe the “Where from” and other attributes from files during sharing. Others may retain the information or overwrite it. To be sure the original location is not embedded in the metadata, you can delete it via Terminal.

Deleting Where Froms in Files

Open the Terminal app on macOS, then enter the command below, replacing with the path to the file. The easiest way is to delete or omit from the command and then drag and drop the file into Terminal, ensuring there is still a space before your file’s path.

xattr -d com.apple.metadata:kMDItemWhereFroms 

For example:

xattr -d com.apple.metadata:kMDItemWhereFroms /Users/gadgethacks/Downloads/GadgetHacksLogo-WR.png

Here, we’re using xattr, short for extended attributes, your Mac’s built-in command-line tool for managing name:file pairs permanently embedded in a file’s metadata. For the command-line argument, -d is used to delete the information stored in com.apple.metadata:kMDItemWhereFroms for the file.

You can then open up the info pane for the file to verify the attribute is gone.

Before and after deleting the “Where from” attribute.

Changing Where Froms in Files

If you want to change the URL currently assigned to the “Where from” metadata attribute, use the following command in Terminal. This is useful when you want to provide a cleaner URL when sharing an image, video, or other file with somebody. It also helps you stay more organized and recall the source more easily.

Replace with the URL you want to add to the file; it only seems to work with URLs, so you can’t add regular notes here. Then, replace with the path to the file. Ensure there are still spaces before the new URL and your file’s path.

xattr -w com.apple.metadata:kMDItemWhereFroms  

For example:

xattr -w com.apple.metadata:kMDItemWhereFroms https://gthx.app/z8ypy /Users/gadgethacks/Downloads/GadgetHacksLogo-RW.png

Here, we’re using -w to write over the value of the attribute’s string with whatever URL precedes the file’s location. You can have or omit https:// in front of the URL — it doesn’t matter. If the URL has special characters, you can try to enclose the complete URL within “double quotation marks” so that it doesn’t get confused, but simpler URLs seem to work over complicated ones.

You can then open up the info pane for the file to verify the attribute is gone.

Before and after renaming the “Where from” attribute.

Learning More

If you want to know what else xattr can help you accomplish with other extended metadata attributes, enter the help command into a Terminal window:

xattr --help

Or use this, where “h” stands for help:

xattr -h

Either should spit out a help page with other flags to use:

usage: xattr [-l] [-r] [-s] [-v] [-x] file [file ...]
       xattr -p [-l] [-r] [-s] [-v] [-x] attr_name file [file ...]
       xattr -w [-r] [-s] [-x] attr_name attr_value file [file ...]
       xattr -d [-r] [-s] attr_name file [file ...]
       xattr -c [-r] [-s] file [file ...]

The first form lists the names of all xattrs on the given file(s).
The second form (-p) prints the value of the xattr attr_name.
The third form (-w) sets the value of the xattr attr_name to the string attr_value.
The fourth form (-d) deletes the xattr attr_name.
The fifth form (-c) deletes (clears) all xattrs.

options:
  -h: print this help
  -l: print long format (attr_name: attr_value and hex output has offsets and
      ascii representation)
  -r: act recursively
  -s: act on the symbolic link itself rather than what the link points to
  -v: also print filename (automatic with -r and with multiple files)
  -x: attr_value is represented as a hex string for input and output




Just updated your iPhone? You’ll find new features for Podcasts, News, Books, and TV, as well as important security improvements and fresh wallpapers. Find out what’s new and changed on your iPhone with the iOS 17.5 update.

Cover photo and screenshots by Justin Meyers/Gadget Hacks



READ SOURCE

This website uses cookies. By continuing to use this site, you accept our use of cookies.