0

I need to hide all files with .pek extension on Finder (macOS Sierra) automatically.

  • 1
    Do you want it as a one shot solution? Or every time when the new file with .pek extension is created? – Mateusz Szlosek May 28 '18 at 11:44
  • I need it every time when the new file with .pek extension is created. Thanks! – Proamagna TV May 28 '18 at 11:56
  • So you need to check this thread: apple.stackexchange.com/questions/63470/… TL;DR: there's no direct way of doing this, you have to create a service for that. – Mateusz Szlosek May 28 '18 at 12:01
  • I try understand it, but I think my knowledge is a little poor. Right now, I'm a little lost. I don't know how create a WatchPaths to run a script about my question. I need help! :( Ah! Also I seen different options with Automator, but I think that it's not possible. Thanks! – Proamagna TV May 28 '18 at 14:09
  • You can easily change the filenames to .filenames. then you can set show hidden files to off. The . (dot) in front of file names will prevent these files from being shown with show hidden files set to off. I don't know how to automate this but I'm sure its doable. – jmh May 29 '18 at 2:37
1

OK I've changed the Peter Hosey's fs-notifier, so that it will set the newly created .pak files hidden. You will need Xcode for the compilation.

Please change those lines in his code:

In Notifier.m change 25th line to:

 stream = FSEventStreamCreate(kCFAllocatorDefault, newCallback, &context, (CFArrayRef)paths, kFSEventStreamEventIdSinceNow, /*latency*/ 1.0, kFSEventStreamCreateFlagUseCFTypes | kFSEventStreamCreateFlagFileEvents);`

In fs-notifier.m file change the whole body of the gotEvent fuction (lines 34+) to:

NSArray *eventPaths = eventPathsVoidPointer;
if (*eventFlags | kFSEventStreamCreateFlagFileEvents) {
    NSURL *fileUrl = [[NSURL alloc] initWithString:[@"file://" stringByAppendingString:[eventPaths objectAtIndex:0UL]]];
    if ([fileUrl.pathExtension isEqualToString:@"pak"]) {
        [fileUrl setResourceValue:@YES forKey:NSURLIsHiddenKey error:nil];
    }
}

Note: In order to compile the sources you might need to set the 64bit architecture.

After the compilaton you'll launch the program with the path to the directory you want to monitor.

I've tested it and it works, however I don't know what's the impact on the system.

Edit: To hide .pak files already created, run this command:

find -x /path/to/folder -name \*.pak -exec chflags hidden {} +

Answer from superuser.

|improve this answer|||||

You must log in to answer this question.

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