6

I've been trying to copy an archive volume from one network share to another. Because most of these files are Mac files, I am using Mac Terminal to do so. I've tried every combination of cp, rsync, and ditto that I could come up with.

The problem lies in the fact that many of these files have a similar name and every once in a while I'll come across one that has a tilde character in the file name. Depending on what variation of cp or rsync command I use, when it comes across this it either fails, stating that file already exists, or, skips the file with the tilde all together and continues on with the process.

For example: "28910 BP Umba Show.SIT" is treated as identical to "28910B~1.SIT" and therefore will not copy to the new archive location.

Any help is greatly appreciated, thanks in advance.

  • That filename example appears to have some non-displayable characters in it, somehow, which is causing the problem. What volume structures are the Network Shares, and what protocols are being used? Is this an all-Mac setup, or are you transferring from or to a Windows or other OS? I would suggest you take a look at the app A Better Finder Rename, which has some very powerful features, including massaging filenames to conform to naming conventions on different OS's. Perhaps ABFN can help. Disclaimer: I'm a happy user of ABFN - no financial tie. – IconDaemon Jul 6 '17 at 22:46
  • 1
    The ~1 ending makes me think the files are or were on a winXP/DOS compatible file system. Have you checked the files are not actually identical? Win 8.3 naming ought to have the actual full names stores in a meta file somewhere, but it's so long since I dealt with it I can't remember where :/ – Tetsujin Jul 7 '17 at 6:07
  • The files are not identical, they vary in size and have different files within. The .sit output is from a archive management tool called "Stuffit". It seems to be some sort of compression tool. The network shares are Windows and they are presented to the macs via Acronis Connect. I am using afp although smb is enabled as well. I will look at ABFN. Thanks. – user1539563 Jul 7 '17 at 21:18
  • 2
    Stuffit was for a long time the 'go to' compression format on Mac until zip took over with OS X. Inherently, there is nothing illegal in the filename 28910B~1.SIT & the Mac should not consider it to be the same as 28910 BP [anything]. Perhaps the remote filesystem/OS is getting in the way? I'd try dragging at least a test folder just using the Finder, to your mac, then back to the new server, just to see what happens. – Tetsujin Jul 8 '17 at 9:14
3

The filename 28910B~1.SIT looks like an MS-DOS abbreviated file name that has more than the 8.3 characters (long file names).

It's important to note that from Windows 2000, both the long name and the shortened 8.3 name were retained (the file had both names)

...when an application saves a file on a computer running Windows 2000, both the 8.3 file name and long file name are retained.

For example, 28910 BP Umba Show.SIT is automatically abbreviated to 28910B~1.SIT and duplicates are incremented (28910B~2.SIT, 28910B~3.SIT, 28910B~4.SIT, etc.) You can read more about this naming convention on Microsoft Tech Network

There's a good chance it's a dupe of one of your files, but the only way to know for certain is to open both and verify.

From the comment:

Either way, I need some magic that will copy the archive and ignore the tilde.

It can't ignore the tilde - it's there and it must be dealt with; as far as macOS is concerned, the two files have identical names (because they do).

To copy both files but not overwrite the one already in the destination folder, you can to a quick test in your command to see if the file already exists in a for/do loop:

for file in /source/directory; do $time=date +%s; if [[ -f /target/directory/$file ]]; then cp $file ${file}-${time}; else cp $file /target/directory/$file; fi; done

This command will parse through your source directory, check if the file exists in the target directory, if it does it will copy the file over appending the current time in seconds (to ensure no multiple dupes); if no dupe exists, it just copies the file over.

  • It's some sort of archive management file structure. I don't think it's dos but the files are very old(circa 2004). They are mac files being saved to a Windows share. Either way, I need some magic that will copy the archive and ignore the tilde. Thanks – user1539563 Jul 7 '17 at 21:25
  • 1
    I updated the answer - They are mac files being saved to a Windows share. This is the crux of the matter right there. It doesn't matter what platform it was created on, it was stored on a Windows machine which meant it created the 8.3 filename to ensure compatibility; circa 2004 is in that time period which is want the article I linked described. – Allan Jul 8 '17 at 11:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .