Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
What makes a file on the Mac unique? How does MacOS (Mojave and otherwise) distinguish one file from another? And can it be changed?
Let me explain what I discovered:

1) If I create a PDF file from a web page in Safari (File-Print-PDF-Save as PDF), save it (i.e. "test1.pdf")
- then make a copy of it in the Finder (naming it to "test2.pdf") I noticed that these files are essentially recognized as the same file. I noticed this when attempting to transfer them over to an iPad.

2) If I create a PDF file from a web page in Safari (File-Print-PDF-Save as PDF), save it (i.e. "test1.pdf")
- then create another PDF file from the exact same web page in Safari (and save it as "test2.pdf") I noticed that these files are recognized as two different files as far as the iPad transfer goes.

I'm asking because I sometimes need to transfer multiple copies of the same PDF over to my iPad, but as noted above it'll refuse to do that. Obviously I can follow step #1 above to solve the problem with PDFs I create myself, but how about other PDF files which I've received from elsewhere? After copying a file (in the Finder), is there a way to edit or re-assign it a new file-identifying ID or whatever the OS uses?
 

ssmed

macrumors 6502a
Sep 28, 2009
875
413
UK
On most Mac OS file systems the name is unique with no reference to capitalisation. In some copying operations finder will automatically append copy onto the file name as an alternative to ask whether to replace or keep a copy.
Test1.pdf = TEst1.pdf = TEST1.pdf etc.

In Mac OS the only clear time I can think of where there is automatic renaming is when multiple files with the same name are copied from the different locations after a search.

In your example the creation and modification date will be the same in example 1 and different in example 2. I don't really do iOS, but imagine that is what is being considered although the names are different so that seems odd.
 

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
In your example the creation and modification date will be the same in example 1 and different in example 2. I don't really do iOS, but imagine that is what is being considered although the names are different so that seems odd.

What you said here got me thinking: can it be that file creation and modification dates determines if a file is seen as being the same or uniquely different!
This has also got me asking myself how Mac apps that look for duplicates work -do they look for identical looking filenames (File1.png and File1 copy.png), identical file sizes, identical creation and modification dates as you pointed out above, a combination of all the above, or even looking inside the file to see if the actual content is the same?

I can't say I've run into any problems in MacOS, but have been frustrated a while over the fact that some PDFs don't appear on my iPad after a transfer, and there's not much I could do about it.

Maybe try tagging them different colors?

Excellent idea!
I'm going to try that and also also remembered that I actually have an app called A Better Finder Attributes which I can use to change a copied file's creation/modification times and dates.
Having done this I'm going to see if they transfer correctly to the iPad.
 

ssmed

macrumors 6502a
Sep 28, 2009
875
413
UK
re: This has also got me asking myself how Mac apps that look for duplicates work

Apps that look for duplicates usually create a HASH and compare those with a high rate of success. Ultimately unless you are going to compare each file line by line this appears a very safe compromise
 

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
Apps that look for duplicates usually create a HASH and compare those with a high rate of success. Ultimately unless you are going to compare each file line by line this appears a very safe compromise

You might be on to something here because I've tried modifying copies of the original PDF in multiple ways without any success -when transferring to the iPad, whichever copy that was last transferred replaces the original already there, regardless of which of the following methods I've used to modify the copy:

- added a MacOS Finder label to a copy
- changed the creation date and time of a copy (using A Better Finder Attributes on the Mac)
- changed the modification date and time of a copy (using A Better Finder Attributes on the Mac)

And of course all the files have unique filenames, while still having some parts of the filename in common (so they can be looked up in an iPad search):

A1 test ORIGINAL.PDF
A2 test COPY.PDF
A3 test FINDER LABEL.PDF
A4 test CREATION TIME AND DATE.PDF
A5 test MODIFICATION TIME AND DATE.PDF

What I've done to test all this to attach the iPad to my Mac with a USB cable, then opened up iTunes on the Mac and selected the contents of the iPad's books section (allowing me to add or delete PDF files).
On the iPad I've opened up the Books app and searched for "test" which of course brings up any of the files above.

OK, so no file-modifications I've tried out so far makes the iPad recognize them as different files. The only thing that works is if I create two files and transfer them to the iPad. I can handle this if I'm doing a PDF print from a web browser (repeating the process twice, which effectively creates a new file twice), but I have no idea what to do about PDF files made by others which I need to transfer multiple copies of.
If the only way to solve this is by having different Hash values I suppose there's no way around it, because isn't a Hash value used as a security measure to ensure that a file is legit, and this value can't be changed?
 

saudor

macrumors 68000
Jul 18, 2011
1,507
2,082
it’s also how APFS works. when you duplicate a file, it references the same file. so even if you duplicate it a million times, it takes up as much space as that one file. it’s only when changes are made that the files “become different”
 
  • Like
Reactions: Nermal

Slartibart

macrumors 68030
Aug 19, 2020
2,892
2,597
How are the duplicates transferred from the Mac to the iPad?
I asked, because I do not have any problems to copy all duplicates of a single file from a macOS-shared folder or via iCloud to an iPad using Apple‘s Files or Filebrowser Pro.

If you run into problems copying the duplicates from the Mac to the iPad, and if it just that you want to keep several copies/duplicates of the same file for whatever reasons on your iPad, why not just use Apple‘s Shortcuts and create the wanted number of duplicates on the iPad?

E.g.:

IMG_2363.jpeg
 

Icelus

macrumors 6502
Nov 3, 2018
376
494

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
How are the duplicates transferred from the Mac to the iPad?
I asked, because I do not have any problems to copy all duplicates of a single file from a macOS-shared folder or via iCloud to an iPad using Apple‘s Files or Filebrowser Pro.

I have my iPad connected with a USB cable to my Mac.
On the Mac I'm using iTunes where I just drag & drop the PDF files in question, which are then transferred over to the iPad.
The problem isn't that the duplicate files (with new, unique filenames) haven't been transferred over to the iPad, because I can verify that they are by clicking on "Books" in the "On my device" section in iTunes to see that they are (see screenshot below), but rather that they aren't accessible in the iPad Books app.
Screenshot 2023-06-18 at 23.16.09.png



If you run into problems copying the duplicates from the Mac to the iPad, and if it just that you want to keep several copies/duplicates of the same file for whatever reasons on your iPad, why not just use Apple‘s Shortcuts and create the wanted number of duplicates on the iPad?

Thanks for the screenshot. I don't think this will solve the problem in question (or I'm misunderstanding), but I'll look into it.
I did however manage to resolve the problem this time around (by saving multiple instances of the PDF files in question instead of merely copying it), but it might get trickier if next time I want to transfer multiple copies of a file I can't edit or re-create.
 

Basic75

macrumors 68000
May 17, 2011
1,949
2,270
Europe
What makes a file on the Mac unique? How does MacOS (Mojave and otherwise) distinguish one file from another?
The term you are probably looking for is "inode". An inode identifies a file system object. With hard links, a single inode can appear in multiple places in the directory hierarchy.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.