Hidden folders/files, moving from Linux to Windows (or how to change dot to hidden attribute)

Good day folks,

I'll be moving my movie collection from Linux based standalone NASes (one is old D-Link Sharecenter and other one is WD MyCloud) to server based on Win Server 2016.
Is there a way to automate tagging files/folders with names like ". HiddenFile.mkv" (yes, that is dot followed by space at the beginning) or ".Hidden Folder" to be assigned hidden attribute under windows and renamed to remove dot or dot followed by space?

I'm hoping for some PowerShell magic.

Thank You!

Ethan

Might be a way to go?

The problem is they actually aren't marked as hidden once I move them to windows machine, they just start with dot or dot and space.

Yeah, but I'm thinking might GNUWin32/64/CoreUtils be capable of tagging .something named files as hidden, I haven't actually tried though.

If I search for .* it also includes anything with extension, that's why I was hoping for some powershell magic so it would exclude extension from search. Also, if I include space in there ". *" it also gets ignored.

get-childitem $path -recurse -exclude *.Exe ?

That would only exclude exe's. But you might be able to write an exclude that has to have at least 1 character before the dot, and use .* instead. Unfortunately I don't know what ruleset the PowerShell RegEx follows...

edit: and theres also -include you could use, in fact best webpage to look through might be:
https://technet.microsoft.com/en-us/library/ee176841.aspx

so maybe

Get-ChildItem -path $path\*. * -recurse -exclude *.txt,*.log *.exe -Force | foreach {$_.attributes = "Hidden"} ?

I thought something like .+[\.]* for the exclude, but in RegexPal (hope the link works) this also matches dotfiles for some reason :confused: (I'm not good with regex)

/edit
actually the link matches differently then when I edited it .. ? what :smiley:
/edit2
nevermind, just add a new line and it looks like mine, small bug in the thingy.

ooohhh that can't work, it matches the dot multiple times -__-

[\w\d\s][\.].* seems to work, but when I add a * to the first group it finds everything again... soooo, weird...

/edit3
This works:
.+[\.].+ - Any character one or more times [dot] any character one or more times.

Interestingly

get-childitem $path -recurse -include ".*",". *"

Seems to work to at least list all the stuff I need

Well since you don't have a wildcard before the dot I'd expect so to be honest.

Ok, thank you guys for brainstorming :slight_smile:

get-childitem $path -recurse -include ".*",". *" | foreach {$_.Attributes = 'Hidden'}

For future reference, this is what I needed.

2 Likes

great, so it worked out. Yeah, and sorry, I couldn't be bothered to install powershell to actually test it out, left that up to you. :stuck_out_tongue:

Isn't PowerShell pre-installed since Vista ... ?

eh, perhaps, but for whatever reason I remembered it differently. :stuck_out_tongue: