Created
September 23, 2018 14:10
-
-
Save toshi0383/41b7d3bcc27ae01246558114da6bcdd7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// script to retrieve these file extensions. | |
// | |
// (for i in $(/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep ' \.[a-zA-Z][a-zA-Z]*' | sed -n 's/.*: *\(.*\)/\1/p' | sort | uniq | sed "s,[ '],,g" | sed 's/,/ /g'); do echo $i; done) | grep '^\.' | grep -v '^\.\.*$' | sort | uniq | sed 's/\(.*\)/"\1",/' | |
// | |
let allFileExtensions = [ | |
"3gp", | |
"3gpp", | |
"Mac", | |
"SGI", | |
"WAV", | |
"aa", | |
"aac", | |
"aae", | |
"aaf", | |
"aax", | |
"abbu", | |
"abc", | |
"abcdg", | |
"abcdp", | |
"ac3", | |
"action", | |
"ada", | |
"adb", | |
"ads", | |
"adts", | |
"afploc", | |
"agilekeychain", | |
"ai", | |
"aif", | |
"aifc", | |
"aiff", | |
"amr", | |
"aplibrary", | |
"aplmodel", | |
"apns", | |
"app", | |
"appdownload", | |
"appex", | |
"applescript", | |
"arobject", | |
"artrace", | |
"arw", | |
"as", | |
"asf", | |
"asl", | |
"asm", | |
"astc", | |
"asx", | |
"atloc", | |
"au", | |
"aupreset", | |
"avchd", | |
"avci", | |
"avi", | |
"band", | |
"basebinary", | |
"bash", | |
"bdm", | |
"bdmv", | |
"bin", | |
"blank", | |
"bmp", | |
"book", | |
"booktemplate", | |
"build", | |
"bundle", | |
"bwf", | |
"bz", | |
"bz2", | |
"bzip2", | |
"c", | |
"c++", | |
"caction", | |
"caf", | |
"cannedsearch", | |
"cc", | |
"ccl", | |
"cdda", | |
"cdr", | |
"cel", | |
"cer", | |
"cert", | |
"certauthorityconfig", | |
"certsigningrequest", | |
"cfr", | |
"chat", | |
"cin", | |
"circleci", | |
"cl", | |
"class", | |
"clipping", | |
"clp", | |
"clr", | |
"cmm", | |
"colorpicker", | |
"command", | |
"component", | |
"configprofile", | |
"cp", | |
"cpgz", | |
"cpio", | |
"cpp", | |
"cr2", | |
"crash", | |
"crt", | |
"crw", | |
"crx", | |
"csh", | |
"css", | |
"csstore", | |
"csv", | |
"ctrl", | |
"cxx", | |
"dae", | |
"dart", | |
"dbwidget", | |
"dc42", | |
"dcm", | |
"dcr", | |
"dds", | |
"definition", | |
"defs", | |
"der", | |
"developerprofile", | |
"dfont", | |
"diag", | |
"dic", | |
"dicom", | |
"dictionary", | |
"dif", | |
"diff", | |
"diskcopy42", | |
"dist", | |
"distz", | |
"dll", | |
"dls", | |
"dlyan", | |
"dmg", | |
"dmgpart", | |
"dng", | |
"doc", | |
"docm", | |
"docset", | |
"docx", | |
"dot", | |
"dotm", | |
"dotx", | |
"download", | |
"dsclext", | |
"dstheme", | |
"dsym", | |
"dtps", | |
"dv", | |
"dvdmedia", | |
"dvdr", | |
"dvticonspec", | |
"dvtplugin", | |
"dxo", | |
"dylib", | |
"eac3", | |
"ec3", | |
"edn", | |
"efx", | |
"eml", | |
"emlx", | |
"emlxpart", | |
"enex", | |
"entitlements", | |
"eps", | |
"epub", | |
"erf", | |
"etd", | |
"eval", | |
"ewsmbox", | |
"exe", | |
"exp", | |
"exr", | |
"f", | |
"f4a", | |
"f4b", | |
"f4p", | |
"f4v", | |
"f77", | |
"f90", | |
"f95", | |
"fdf", | |
"fff", | |
"fileloc", | |
"flac", | |
"flc", | |
"fli", | |
"flv", | |
"for", | |
"fpbf", | |
"fpx", | |
"frag", | |
"fragment", | |
"fragsh", | |
"framework", | |
"fs", | |
"fsh", | |
"ftploc", | |
"game", | |
"gbproj", | |
"gcx", | |
"geojson", | |
"geom", | |
"geometry", | |
"gif", | |
"git", | |
"gitattributes", | |
"gitignore", | |
"glsl", | |
"gpurestart", | |
"gputrace", | |
"gpx", | |
"gs", | |
"gsh", | |
"gtar", | |
"gz", | |
"gzip", | |
"h", | |
"h++", | |
"hang", | |
"hdr", | |
"heic", | |
"heif", | |
"help", | |
"hh", | |
"hp", | |
"hpp", | |
"hqx", | |
"htm", | |
"html", | |
"hvpl", | |
"hxx", | |
"i", | |
"iba", | |
"ibatemplate", | |
"ibooks", | |
"ibplugin", | |
"icbu", | |
"icc", | |
"ichat", | |
"ichattransfer", | |
"icloud", | |
"icm", | |
"icns", | |
"ico", | |
"iconset", | |
"ics", | |
"ideplugin", | |
"ii", | |
"iiq", | |
"ilmbplugin", | |
"imapmbox", | |
"img", | |
"imgpart", | |
"imovielibrary", | |
"inetloc", | |
"inl", | |
"inputplugin", | |
"instrdst", | |
"instrpkg", | |
"intentdefinition", | |
"internetconnect", | |
"ipa", | |
"ipg", | |
"ipmeta", | |
"ipp", | |
"ipspot", | |
"ipsw", | |
"iso", | |
"ite", | |
"itermcolors", | |
"itl", | |
"itlb", | |
"itlp", | |
"itms", | |
"itmsp", | |
"itmsp-app", | |
"itpc", | |
"j2c", | |
"j2k", | |
"jar", | |
"jav", | |
"java", | |
"javascript", | |
"jfx", | |
"jhtml", | |
"jnlp", | |
"jp2", | |
"jpe", | |
"jpeg", | |
"jpf", | |
"jpg", | |
"jpx", | |
"js", | |
"jscript", | |
"json", | |
"kar", | |
"kext", | |
"kextcache", | |
"key", | |
"key-tef", | |
"keychain", | |
"keychain-db", | |
"ksh", | |
"kth", | |
"ktrace", | |
"ktx", | |
"l", | |
"ldi", | |
"ldif", | |
"legacyagilekeychain", | |
"lid", | |
"lm", | |
"lmm", | |
"log", | |
"logarchive", | |
"loginplugin", | |
"lpdf", | |
"lpp", | |
"lsr", | |
"lwfn", | |
"lxx", | |
"m", | |
"m15", | |
"m2ts", | |
"m2v", | |
"m3u", | |
"m3u8", | |
"m4a", | |
"m4b", | |
"m4p", | |
"m4r", | |
"m4v", | |
"m75", | |
"mailloc", | |
"mailstationery", | |
"make", | |
"markdown", | |
"mbox", | |
"md", | |
"mdimporter", | |
"mdml", | |
"mdown", | |
"mdwn", | |
"memgraph", | |
"menu", | |
"messagestransfer", | |
"metal", | |
"mht", | |
"mhtml", | |
"mi", | |
"mid", | |
"midi", | |
"mig", | |
"migratedaplibrary", | |
"migratedphotolibrary", | |
"mii", | |
"minc", | |
"mkd", | |
"mkext", | |
"mkpdf", | |
"mlkitmodel", | |
"mlmodel", | |
"mm", | |
"mmd", | |
"mnc", | |
"mobile", | |
"mobileconfig", | |
"mobileprovision", | |
"mode0", | |
"mode0v3", | |
"mode1", | |
"mode1v3", | |
"mode2", | |
"mode2v3", | |
"mode3", | |
"mode3v3", | |
"modulemap", | |
"mom", | |
"monitorpanel", | |
"mos", | |
"mov", | |
"mp2", | |
"mp3", | |
"mp4", | |
"mpe", | |
"mpeg", | |
"mpg", | |
"mpg4", | |
"mpga", | |
"mpkg", | |
"mpo", | |
"mrw", | |
"mts", | |
"mxf", | |
"nasm", | |
"ndif", | |
"nef", | |
"networkconnect", | |
"newsloc", | |
"nib", | |
"nii", | |
"nmbtemplate", | |
"notesairdropdocument", | |
"notesarchive", | |
"nrw", | |
"nslloc", | |
"numbers", | |
"numbers-tef", | |
"nvf", | |
"o", | |
"obj", | |
"octest", | |
"odb", | |
"odc", | |
"odf", | |
"odg", | |
"odi", | |
"odm", | |
"odp", | |
"ods", | |
"odt", | |
"oga", | |
"ogg", | |
"ogv", | |
"omf", | |
"onepassword-item-metadata", | |
"opvault", | |
"orf", | |
"osax", | |
"otc", | |
"otf", | |
"otg", | |
"oth", | |
"oti", | |
"otp", | |
"ots", | |
"ott", | |
"p10", | |
"p12", | |
"p7", | |
"p7b", | |
"p7c", | |
"p7m", | |
"p7r", | |
"p7s", | |
"pages", | |
"pages-tef", | |
"panic", | |
"pas", | |
"patch", | |
"pax", | |
"pbm", | |
"pbproj", | |
"pbxproj", | |
"pbxuser", | |
"pcast", | |
"pch", | |
"pch++", | |
"pct", | |
"pdf", | |
"pef", | |
"pem", | |
"persistentcardmodel", | |
"perspective", | |
"perspectivev3", | |
"pf", | |
"pfa", | |
"pfb", | |
"pfm", | |
"pfx", | |
"pgm", | |
"pgn", | |
"ph3", | |
"ph4", | |
"photobooth", | |
"photolibrary", | |
"photoslibrary", | |
"php", | |
"php3", | |
"php4", | |
"phtml", | |
"pic", | |
"pict", | |
"pictclipping", | |
"pkcs12", | |
"pkg", | |
"pkpass", | |
"pl", | |
"playground", | |
"playgroundbook", | |
"plist", | |
"pls", | |
"plugin", | |
"plugindata", | |
"pluginkit", | |
"ply", | |
"pm", | |
"png", | |
"pntg", | |
"pot", | |
"potm", | |
"potx", | |
"ppm", | |
"ppp", | |
"pps", | |
"ppsm", | |
"ppsx", | |
"ppt", | |
"pptm", | |
"pptx", | |
"prefpane", | |
"proto", | |
"prototrace", | |
"provisionprofile", | |
"ps", | |
"psd", | |
"psdownload", | |
"pset", | |
"pvr", | |
"pvt", | |
"pwl", | |
"py", | |
"qlgenerator", | |
"qt", | |
"qti", | |
"qtif", | |
"qtpxcomposition", | |
"qtz", | |
"r", | |
"ra", | |
"raf", | |
"ram", | |
"raw", | |
"rb", | |
"rbw", | |
"rdf", | |
"rm", | |
"rmp", | |
"rmvb", | |
"rss", | |
"rst", | |
"rtf", | |
"rtfd", | |
"rw2", | |
"rwl", | |
"s", | |
"safariextz", | |
"sample.txt", | |
"savedsearch", | |
"saver", | |
"scc", | |
"scn", | |
"scnassets", | |
"scnp", | |
"scnz", | |
"scpt", | |
"scptd", | |
"scriptsuite", | |
"scriptterminology", | |
"sd2", | |
"sda", | |
"sdc", | |
"sdd", | |
"sdef", | |
"sdp", | |
"sdv", | |
"sdw", | |
"sea", | |
"seplugin", | |
"service", | |
"sf2", | |
"sfont", | |
"sgi", | |
"sh", | |
"shlb", | |
"shtm", | |
"shtml", | |
"shutdownstall", | |
"sidx", | |
"simdevicetype", | |
"simruntime", | |
"sit", | |
"sitx", | |
"sketch", | |
"sketchdefault", | |
"sketchplugin", | |
"sketchpreset", | |
"sks", | |
"slidesaver", | |
"slm", | |
"smf", | |
"smi", | |
"snd", | |
"sndclipping", | |
"sparsebundle", | |
"sparseimage", | |
"spin", | |
"spreporter", | |
"spx", | |
"sr2", | |
"srf", | |
"srw", | |
"ssdownload", | |
"stc", | |
"std", | |
"sti", | |
"stickerpack", | |
"stl", | |
"storyboard", | |
"storyboardc", | |
"strings", | |
"stringsdict", | |
"stw", | |
"sucatalog", | |
"suggestionsassets", | |
"suit", | |
"svg", | |
"svgz", | |
"swift", | |
"sxc", | |
"sxd", | |
"sxg", | |
"sxi", | |
"sxm", | |
"sxw", | |
"tailspin", | |
"tar", | |
"tbz", | |
"tbz2", | |
"tcl", | |
"tcsh", | |
"template", | |
"term", | |
"terminal", | |
"text", | |
"textclipping", | |
"tga", | |
"tgz", | |
"theater", | |
"thmx", | |
"tif", | |
"tiff", | |
"toast", | |
"tool", | |
"trace", | |
"tracetemplate", | |
"ts", | |
"tsv", | |
"ttc", | |
"ttf", | |
"txt", | |
"txz", | |
"udif", | |
"ul", | |
"ulaw", | |
"ulw", | |
"url", | |
"usd", | |
"usda", | |
"usdc", | |
"uu", | |
"vcal", | |
"vcard", | |
"vcf", | |
"vcs", | |
"vert", | |
"vertex", | |
"vfw", | |
"vncloc", | |
"voprefs", | |
"vs", | |
"vsh", | |
"war", | |
"wav", | |
"wave", | |
"wax", | |
"wdgt", | |
"wdmon", | |
"webarchive", | |
"webbookmark", | |
"webhistory", | |
"webloc", | |
"webm", | |
"webp", | |
"webplugin", | |
"wflow", | |
"wm", | |
"wma", | |
"wmp", | |
"wmv", | |
"wmx", | |
"workflow", | |
"wvx", | |
"xar", | |
"xbl", | |
"xbm", | |
"xcappdata", | |
"xcarchive", | |
"xcassets", | |
"xcconfig", | |
"xccrashpoint", | |
"xcdatamodel", | |
"xcdatamodeld", | |
"xcfilelist", | |
"xcloc", | |
"xcmappingmodel", | |
"xcode", | |
"xcodeproj", | |
"xcplaygroundpage", | |
"xcplugin", | |
"xcplugindata", | |
"xcprocessorusagelog", | |
"xcprocessorusagepoint", | |
"xcresult", | |
"xcscheme", | |
"xcsintegration", | |
"xcsnapshots", | |
"xcstickers", | |
"xctest", | |
"xctestrun", | |
"xctoolchain", | |
"xcworkspace", | |
"xfd", | |
"xfdf", | |
"xht", | |
"xhtm", | |
"xhtml", | |
"xib", | |
"xip", | |
"xla", | |
"xlam", | |
"xlc", | |
"xlf", | |
"xliff", | |
"xlm", | |
"xls", | |
"xlsb", | |
"xlsm", | |
"xlsx", | |
"xlt", | |
"xltm", | |
"xltx", | |
"xlw", | |
"xml", | |
"xmp", | |
"xpc", | |
"xsl", | |
"xslt", | |
"xul", | |
"xz", | |
"y", | |
"ym", | |
"ymm", | |
"ypp", | |
"yxx", | |
"z", | |
"zip", | |
"zsh", | |
] | |
let fm = FileManager.default | |
allFileExtensions | |
.forEach { ex in | |
do { | |
let file = "./tmp/a.\(ex)" | |
// try "".write(toFile: file, atomically: false, encoding: .utf8) | |
try fm.createDirectory(atPath: file, withIntermediateDirectories: true, attributes: nil) | |
let uti = try URL(fileURLWithPath: file) | |
.resourceValues(forKeys: [URLResourceKey.typeIdentifierKey]) | |
.typeIdentifier! | |
try fm.removeItem(atPath: file) | |
//print("ex: \(ex), uti: \(uti)") | |
//if uti != "public.folder" && !uti.starts(with: "dyn") { | |
//} else { | |
let ws = String((0..<max(25-ex.count, 1)).map { _ in " " }.joined()) | |
print("\"\(ex)\",\(ws)// \(uti)") | |
//} | |
} catch { | |
fatalError("\(error)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment