Homebrew macOS - Fix archive attributes for switch SD card

Player_One

Member
Newcomer
Joined
Aug 9, 2019
Messages
12
Trophies
0
Age
33
XP
203
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

  • switchSD_3.4.zip
    141.3 KB · Views: 513
Last edited by Player_One,

stick267

Well-Known Member
Member
Joined
Dec 17, 2018
Messages
598
Trophies
0
Age
30
XP
1,124
Country
United States
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.
 

Player_One

Member
Newcomer
Joined
Aug 9, 2019
Messages
12
Trophies
0
Age
33
XP
203
Country
Russia
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)
 

Player_One

Member
Newcomer
Joined
Aug 9, 2019
Messages
12
Trophies
0
Age
33
XP
203
Country
Russia
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,

Tumbleweed

Well-Known Member
Member
Joined
Jul 29, 2018
Messages
106
Trophies
0
Age
37
XP
835
Country
Italy
Until now I've used Parallels to manage all my switch transfers, one corruption so far, I will give this a try, tkyvm!
 

sorabora

Well-Known Member
Member
Joined
Dec 8, 2016
Messages
344
Trophies
0
XP
1,011
Country
United States
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: 404
Last edited by sorabora,

Player_One

Member
Newcomer
Joined
Aug 9, 2019
Messages
12
Trophies
0
Age
33
XP
203
Country
Russia
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

iNash

Member
Newcomer
Joined
Jul 27, 2018
Messages
6
Trophies
0
Age
38
XP
75
Country
Kuwait
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
 

wiewiec

Well-Known Member
Member
Joined
Dec 24, 2015
Messages
771
Trophies
0
Age
37
Location
Somewhere
XP
1,327
Country
Poland

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
 

KingRaijun

Member
Newcomer
Joined
Apr 18, 2020
Messages
8
Trophies
0
Age
32
XP
39
Country
Philippines
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.
 

bao3

Active Member
Newcomer
Joined
Oct 27, 2019
Messages
33
Trophies
0
Age
38
Website
www.vultr.com
XP
218
Country
China

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
 
General chit-chat
Help Users
    gudenau @ gudenau: I want another tourny.