Homebrew macOS - Fix archive attributes for switch SD card

  • Thread starter Thread starter Player_One
  • Start date Start date
  • Views Views 32,252
  • Replies Replies 33
  • Likes Likes 14

Player_One

Member
Newcomer
Joined
Aug 9, 2019
Messages
12
Reaction score
19
Trophies
0
Age
37
XP
281
Country
Russia
switchSD.png
switchSD

Info:
Mac OS users are having trouble reading an SD card on the Nintendo Switch. This is all because the archive file attribute of HOS (Nintendo Switch OS) and macOS are used for different purposes.
I wrote a small application (applescript) that removes archive attributes for all files and folders on the Switch SD card.
It also takes into account the specificity of .nca folders and fixed them.
And lastly, it cleans up hidden unnecessary files for the Switch that macOS created when you worked with SD through the Finder.
In the new version, you can choose where you want to fix the attributes. On the entire map except the Nintendo folders on it (so as not to violate the attributes of the nca folders)
or you can fix the attributes of the Nintendo folders(if something is wrong with .nca attributes).

How to use:
1. Perform all the actions you need with the files and folders on the switch SD card.

2. Select the name of the SD card from the list.
Screen Shot 2019-09-17 at 1.34.00 AM.png
3. Select a direction to fix:
Screen Shot 2019-09-04 at 12.24.31 AM.png
(a) Fix bit all files - will remove the archive bit for all files and folders on SD except Nintendo folders.
(b) Fix bit Nintendo folders - restore archive bit for all .nca on SD card.

4. Enter the administrator password.
Screen Shot 2019-08-09 at 12.36.07 PM.png

5. (a) Fix bit all files - the process is pretty fast
Screen Shot 2019-09-04 at 12.29.16 AM.png
5. (b) Fix bit Nintendo folders - This process is not fast and depends on the number of .nca on the SD card.
Screen Shot 2019-08-24 at 4.57.16 PM.png

6. Wait for notification of the end of the processes.

Done - Insert the SD card into the Switch.
Screen Shot 2019-08-09 at 12.36.32 PM.png

Note:
You may need to allow applications not installed by Apple developers to be launched.
To do this, run the command in Terminal " sudo spctl --master-disable "
Screen Shot 2019-08-09 at 6.45.14 PM.png


Code:
#switchSD v0.3.4

#by PlayerOne


property rm : "sudo rm -rf "

property arch : "sudo chflags -R arch "


set disksExternal to do shell script "mount | awk '/Volumes/ { print $3 }'"

set diskExternal to every paragraph of disksExternal


choose from list diskExternal with prompt "Select SD card for Nintendo Switch"

set the switchSD to the result

if switchSD is equal to false then return

set switchSD to quoted form of POSIX path of (switchSD as string)


set Fix to button returned of (display dialog "What do you want to fix?" buttons {"Fix bit Nintendo folders", "Fix bit all files"})


do shell script "sudo touch " & switchSD & " .metadata_never_index" with administrator privileges


if Fix is "Fix bit all files" then

    set bitArchFiles to do shell script "find " & switchSD & "/* -path " & switchSD & " -prune -o -path " & switchSD & "/emuMMC -prune -o -path " & switchSD & "/Emutendo -prune -o -path " & switchSD & "/Nintendo -prune -o -depth 0 -print" with administrator privileges

    set archFiles to every paragraph of bitArchFiles

   

    set ProgressDialog to length of archFiles

    set progress total steps to ProgressDialog

    set progress completed steps to 0

    set progress description to "Fix bit all"

    set progress additional description to ""

   

    repeat with bit from 1 to length of archFiles

        set archBit to item bit of archFiles

        set progress additional description to POSIX path of archBit

        do shell script "sudo chflags -R arch " & quoted form of archBit with administrator privileges

        set progress completed steps to bit

    end repeat

end if



if Fix is "Fix bit Nintendo folders" then

    set listNCAs to do shell script "find " & switchSD & "/ -name '*.nca' | grep .nca"

    set NCAs to every paragraph of listNCAs

   

    set ProgressDialog to length of NCAs

    set progress total steps to ProgressDialog

    set progress completed steps to 0

    set progress description to "Fix bit NCA folders"

    set progress additional description to ""

   

    repeat with a from 1 to length of NCAs

        set nca to item a of NCAs

        set progress additional description to POSIX path of nca

        set ncaF to do shell script "echo " & quoted form of nca & " | cut -d'.' -f-1"

        do shell script "mkdir " & quoted form of ncaF with administrator privileges

        do shell script "mv " & quoted form of nca & "/* " & quoted form of ncaF with administrator privileges

        do shell script rm & quoted form of nca with administrator privileges

        do shell script "mv " & quoted form of ncaF & " " & quoted form of (ncaF & ".nca") with administrator privileges

        set progress completed steps to a

    end repeat

end if


set progress total steps to 0

set progress completed steps to 0



do shell script "find " & switchSD & " -name '._*' -delete"

do shell script "find " & switchSD & " -name '.DS_Store' -delete"

do shell script rm & switchSD & "/.metadata_never_index" with administrator privileges

do shell script rm & switchSD & "/.Trashes" with administrator privileges

do shell script rm & switchSD & "/.fseventsd*" with administrator privileges

do shell script rm & switchSD & "/.Spotlight-V100" with administrator privileges



set progress description to "Unmount SD card"

set progress additional description to (switchSD as string)

do shell script "sudo diskutil unmount " & switchSD with administrator privileges

do shell script "afplay /System/Library/Sounds/Glass.aiff"

display notification "SwitchSD- Done" with icon


set progress description to ""

set progress additional description to ""

Version:

switchSD - v0.1
- the script works

switchSD - v0.2
- Added a progress bar to observe the process.

switchSD - v0.3
- The path selection for SD is changed, now the script checks external disks and displays the names.
- Separation of functions on fix bit for everything except .nca and fix bit .nca folders.
- Fixed the work of paths if the disc name contains spaces.

switchSD - v0.3.1
- Fixed bug bit archive for emuMMC folder.

switchSD - v0.3.2
- Changed drive search, now search all drives. The drive name must not contain spaces.

switchSD - v0.3.3
- add touch command .metadata_never_index (fix delete .Spotlight-V100 folder)

switchSD - v0.3.4
- bugfix Spotlight-V100 folder (10.15 too?), add Emutendo folder.
 

Attachments

Last edited by Player_One,
I find myself just using nxmtp to get around all of macOS's archive bit and dot file nonsense, so this could be very useful. Thanks.
 
I find myself just using nxmtp to get around all of macOS's archive bit and dot file nonsense, so this could be very useful. Thanks.
all right. but it’s not always possible to start it homebrew, for example, when you first create an SD for a switch, the “switch” folder also has an archive attribute. And it should be removed for hbmenu to work properly. Also, these attributes interfere if you put mods or translations with titles. The application allows you not to think about it. And so everything is possible with your hands)
 
Sounds like a great app, however I doesn't list my sd card.
This happened because the Apple card reader is PCIe and initializes the SD card as an internal drive. So I redid the external drive search. Now it finds all disks except the system one.
Try the new version (0.3.2).
 
Last edited by Player_One,
Until now I've used Parallels to manage all my switch transfers, one corruption so far, I will give this a try, tkyvm!
 
This helpful tip didn't actually remove those .whatever files. Tried twice, too :\
I added a command that undoes Spotlight indexing on macOS for the selected drive. And it seems to have worked. Please check with yourself switchSD v0.3.3.
 
Oddly enough, those macOS files do not show in Tinfoil-like apps or in NX Shell. SO I think it worked.

They do show up, however, in Goldleaf .73 No idea what's going on.

Image attached is re: nca button error. Got it both times I tried that option. About 50% or so of the way through.
 

Attachments

  • Screen Shot 2019-10-05 at 10.39.35 AM.png
    Screen Shot 2019-10-05 at 10.39.35 AM.png
    116.4 KB · Views: 742
Last edited by sorabora,
Oddly enough, those macOS files do not show in Tinfoil-like apps or in NX Shell. SO I think it worked.

They do show up, however, in Goldleaf .73 No idea what's going on.

Image attached is re: nca button error. Got it both times I tried that option. About 50% or so of the way through.
I will check Goldleaft, I tested only in NX-Shell.
This is not a problem, the script could not unmount the usb disk, I will add a handler for this case. drag the flash drive and restart the script the error should disappear. Thanks)
 
  • Like
Reactions: sorabora
hello its gives me that msg
find: /Volumes/switch/.Trashes: Operation not permitted

find: /Volumes/switch/.Spotlight-V100: Operation not permitted


find: /Volumes/switch/.Trashes: Operation not permitted

find: /Volumes/switch/.Spotlight-V100: Operation not permitted (1)

Mac Os Catalina
 

Info:
Mac OS users are having trouble reading an SD card on the Nintendo Switch. This is all because the archive file attribute of HOS (Nintendo Switch OS) and macOS are used for different purposes.
I wrote a small application (applescript) that removes archive attributes for all files and folders on the Switch SD card.
It also takes into account the specificity of .nca folders and fixed them.
And lastly, it cleans up hidden unnecessary files for the Switch that macOS created when you worked with SD through the Finder.
In the new version, you can choose where you want to fix the attributes. On the entire map except the Nintendo folders on it (so as not to violate the attributes of the nca folders)
or you can fix the attributes of the Nintendo folders(if something is wrong with .nca attributes).

How to use:
1. Perform all the actions you need with the files and folders on the switch SD card.

2. Select the name of the SD card from the list.
View attachment 179649
3. Select a direction to fix:
View attachment 178397
(a) Fix bit all files - will remove the archive bit for all files and folders on SD except Nintendo folders.
(b) Fix bit Nintendo folders - restore archive bit for all .nca on SD card.

4. Enter the administrator password.
View attachment 175936

5. (a) Fix bit all files - the process is pretty fast
View attachment 178396
5. (b) Fix bit Nintendo folders - This process is not fast and depends on the number of .nca on the SD card.
View attachment 177315

6. Wait for notification of the end of the processes.

Done - Insert the SD card into the Switch.
View attachment 175934

Note:
You may need to allow applications not installed by Apple developers to be launched.
To do this, run the command in Terminal " sudo spctl --master-disable "
View attachment 175959


Code:
#switchSD v0.3.3

#by PlayerOne


property rm : "sudo rm -rf "

property arch : "sudo chflags -R arch "


set disksExternal to do shell script "mount | awk '/Volumes/ { print $3 }'"

set diskExternal to every paragraph of disksExternal


choose from list diskExternal with prompt "Select SD card for Nintendo Switch"

set the switchSD to the result

if switchSD is equal to false then return

set switchSD to quoted form of POSIX path of (switchSD as string)


set Fix to button returned of (display dialog "What do you want to fix?" buttons {"Fix bit Nintendo folders", "Fix bit all files"})


do shell script "find " & switchSD & " -name '._*' -delete"

do shell script "find " & switchSD & " -name '.DS_Store' -delete"


if Fix is "Fix bit all files" then

    set bitArchFiles to do shell script "find " & switchSD & "/* -path " & switchSD & " -prune -o -path " & switchSD & "/emuMMC -prune -o -path " & switchSD & "/Nintendo -prune -o -depth 0 -print"

    set archFiles to every paragraph of bitArchFiles

 

    set ProgressDialog to length of archFiles

    set progress total steps to ProgressDialog

    set progress completed steps to 0

    set progress description to "Fix bit all"

    set progress additional description to ""

 

    repeat with bit from 1 to length of archFiles

        set archBit to item bit of archFiles

        set progress additional description to POSIX path of archBit

        do shell script "sudo chflags -R arch " & quoted form of archBit with administrator privileges

        set progress completed steps to bit

    end repeat

end if



if Fix is "Fix bit Nintendo folders" then

    set listNCAs to do shell script "find " & switchSD & "/ -name '*.nca' | grep .nca"

    set NCAs to every paragraph of listNCAs

 

    set ProgressDialog to length of NCAs

    set progress total steps to ProgressDialog

    set progress completed steps to 0

    set progress description to "Fix bit NCA folders"

    set progress additional description to ""

 

    repeat with a from 1 to length of NCAs

        set nca to item a of NCAs

        set progress additional description to POSIX path of nca

        set ncaF to do shell script "echo " & quoted form of nca & " | cut -d'.' -f-1"

        do shell script "mkdir " & quoted form of ncaF with administrator privileges

        do shell script "mv " & quoted form of nca & "/* " & quoted form of ncaF with administrator privileges

        do shell script rm & quoted form of nca with administrator privileges

        do shell script "mv " & quoted form of ncaF & " " & quoted form of (ncaF & ".nca") with administrator privileges

        set progress completed steps to a

    end repeat

end if


set progress total steps to 0

set progress completed steps to 0


do shell script "sudo touch " & switchSD & " .metadata_never_index" with administrator privileges

do shell script "find " & switchSD & " -name '._*' -delete"

do shell script "find " & switchSD & " -name '.DS_Store' -delete"

do shell script rm & switchSD & ".Spotlight-V100" with administrator privileges

do shell script rm & switchSD & ".fseventsd" with administrator privileges

do shell script rm & switchSD & ".Trashes" with administrator privileges


set progress description to "Unmount SD card"

set progress additional description to (switchSD as string)

do shell script "sudo diskutil unmount " & switchSD with administrator privileges

do shell script "afplay /System/Library/Sounds/Glass.aiff"

display notification "SwitchSD- Done" with icon


set progress description to ""

set progress additional description to ""

Version:

switchSD - v0.1
- the script works

switchSD - v0.2
- Added a progress bar to observe the process.

switchSD - v0.3
- The path selection for SD is changed, now the script checks external disks and displays the names.
- Separation of functions on fix bit for everything except .nca and fix bit .nca folders.
- Fixed the work of paths if the disc name contains spaces.

switchSD - v0.3.1
- Fixed bug bit archive for emuMMC folder.

switchSD - v0.3.2
- Changed drive search, now search all drives. The drive name must not contain spaces.

switchSD - v0.3.3
- add touch command .metadata_never_index (fix delete .Spotlight-V100 folder)

I have question if you have plans to update app to handle Catalina, because it is not working correctly and returns errors when I try clean SD. Thanks
 
I use an alternative solution for this since I'm using Mojave.

`sudo chflags -R arch <directory>` (!!!!!) EXCEPT (!!!!!) Nintendo folder of course.

But the tool works most of the time if I delete the Spotlight file.
 

Info:
Mac OS users are having trouble reading an SD card on the Nintendo Switch. This is all because the archive file attribute of HOS (Nintendo Switch OS) and macOS are used for different purposes.
I wrote a small application (applescript) that removes archive attributes for all files and folders on the Switch SD card.
It also takes into account the specificity of .nca folders and fixed them.
And lastly, it cleans up hidden unnecessary files for the Switch that macOS created when you worked with SD through the Finder.
In the new version, you can choose where you want to fix the attributes. On the entire map except the Nintendo folders on it (so as not to violate the attributes of the nca folders)
or you can fix the attributes of the Nintendo folders(if something is wrong with .nca attributes).

How to use:
1. Perform all the actions you need with the files and folders on the switch SD card.

2. Select the name of the SD card from the list.
View attachment 179649
3. Select a direction to fix:
View attachment 178397
(a) Fix bit all files - will remove the archive bit for all files and folders on SD except Nintendo folders.
(b) Fix bit Nintendo folders - restore archive bit for all .nca on SD card.

4. Enter the administrator password.
View attachment 175936

5. (a) Fix bit all files - the process is pretty fast
View attachment 178396
5. (b) Fix bit Nintendo folders - This process is not fast and depends on the number of .nca on the SD card.
View attachment 177315

6. Wait for notification of the end of the processes.

Done - Insert the SD card into the Switch.
View attachment 175934

Note:
You may need to allow applications not installed by Apple developers to be launched.
To do this, run the command in Terminal " sudo spctl --master-disable "
View attachment 175959


Code:
#switchSD v0.3.3

#by PlayerOne


property rm : "sudo rm -rf "

property arch : "sudo chflags -R arch "


set disksExternal to do shell script "mount | awk '/Volumes/ { print $3 }'"

set diskExternal to every paragraph of disksExternal


choose from list diskExternal with prompt "Select SD card for Nintendo Switch"

set the switchSD to the result

if switchSD is equal to false then return

set switchSD to quoted form of POSIX path of (switchSD as string)


set Fix to button returned of (display dialog "What do you want to fix?" buttons {"Fix bit Nintendo folders", "Fix bit all files"})


do shell script "find " & switchSD & " -name '._*' -delete"

do shell script "find " & switchSD & " -name '.DS_Store' -delete"


if Fix is "Fix bit all files" then

    set bitArchFiles to do shell script "find " & switchSD & "/* -path " & switchSD & " -prune -o -path " & switchSD & "/emuMMC -prune -o -path " & switchSD & "/Nintendo -prune -o -depth 0 -print"

    set archFiles to every paragraph of bitArchFiles

 

    set ProgressDialog to length of archFiles

    set progress total steps to ProgressDialog

    set progress completed steps to 0

    set progress description to "Fix bit all"

    set progress additional description to ""

 

    repeat with bit from 1 to length of archFiles

        set archBit to item bit of archFiles

        set progress additional description to POSIX path of archBit

        do shell script "sudo chflags -R arch " & quoted form of archBit with administrator privileges

        set progress completed steps to bit

    end repeat

end if



if Fix is "Fix bit Nintendo folders" then

    set listNCAs to do shell script "find " & switchSD & "/ -name '*.nca' | grep .nca"

    set NCAs to every paragraph of listNCAs

 

    set ProgressDialog to length of NCAs

    set progress total steps to ProgressDialog

    set progress completed steps to 0

    set progress description to "Fix bit NCA folders"

    set progress additional description to ""

 

    repeat with a from 1 to length of NCAs

        set nca to item a of NCAs

        set progress additional description to POSIX path of nca

        set ncaF to do shell script "echo " & quoted form of nca & " | cut -d'.' -f-1"

        do shell script "mkdir " & quoted form of ncaF with administrator privileges

        do shell script "mv " & quoted form of nca & "/* " & quoted form of ncaF with administrator privileges

        do shell script rm & quoted form of nca with administrator privileges

        do shell script "mv " & quoted form of ncaF & " " & quoted form of (ncaF & ".nca") with administrator privileges

        set progress completed steps to a

    end repeat

end if


set progress total steps to 0

set progress completed steps to 0


do shell script "sudo touch " & switchSD & " .metadata_never_index" with administrator privileges

do shell script "find " & switchSD & " -name '._*' -delete"

do shell script "find " & switchSD & " -name '.DS_Store' -delete"

do shell script rm & switchSD & ".Spotlight-V100" with administrator privileges

do shell script rm & switchSD & ".fseventsd" with administrator privileges

do shell script rm & switchSD & ".Trashes" with administrator privileges


set progress description to "Unmount SD card"

set progress additional description to (switchSD as string)

do shell script "sudo diskutil unmount " & switchSD with administrator privileges

do shell script "afplay /System/Library/Sounds/Glass.aiff"

display notification "SwitchSD- Done" with icon


set progress description to ""

set progress additional description to ""

Version:

switchSD - v0.1
- the script works

switchSD - v0.2
- Added a progress bar to observe the process.

switchSD - v0.3
- The path selection for SD is changed, now the script checks external disks and displays the names.
- Separation of functions on fix bit for everything except .nca and fix bit .nca folders.
- Fixed the work of paths if the disc name contains spaces.

switchSD - v0.3.1
- Fixed bug bit archive for emuMMC folder.

switchSD - v0.3.2
- Changed drive search, now search all drives. The drive name must not contain spaces.

switchSD - v0.3.3
- add touch command .metadata_never_index (fix delete .Spotlight-V100 folder)

It post errors on my macOS 15.5 ,


chflags: /Volumes/Untitled/EmuMMC: Operation not permitted




upload_2020-4-20_14-50-9.png
 

Site & Scene News

Popular threads in this forum