15

I've got a MacBook laptop in the house, and when Mac OS X copies files over the network, it often brings along hidden "dot-files" with it. For instance, if I copy "SomeUtility.zip", there will also be copied a hidden ".SomeUtility.zip" file. I consider these OS X dot-files as useless turds of data as far as the rest of my network is concerned, and don't want to leave them on my Windows file server.

Let's assume these dot-files will continue to happen. i.e. Think of the issue of getting OS X to stop creating those files, in the first place, to be another question altogether.

Rather: How can I use Windows Explorer to find files that begin with a dot / period? I'd like to periodically search my file server and blow them away. I tried searching for files matching ".*" but that yielded – and not unexpectedly – all files and folders.

Is there a way to enter more specific search criteria when searching in Windows Explorer? I'm referring to the search box that appears in the upper-right corner of an Explorer window. Please tell me there is a way to escape my query to do what I want?

(Failing that, I know I can map a drive letter and drop into a cygwin prompt and use the UNIX 'find' command, but I'd prefer a shiny easy way.)

1
  • 1
    i thought cygwin was the shiny easy way! :) Apr 18, 2010 at 15:50

7 Answers 7

18

Use Window's "Search Advanced Query Syntax", which basically lets you do stuff that Vista and XP advanced search used to let you (that Windows 7 hid). Read about it on MSDN.

Hence, you can just search filename:. to find all files with a file name that begins with "."

3
7

The windows Command prompt method to find all "dot files" in all directories below the current directory, but excluding directory names beginning with dot:

dir .*.* /s /a-D
3
  • 1
    +1 for not resorting to 3rd party programs, although I think you mean "including directories below", as that's what /s does
    – RJFalconer
    Apr 18, 2010 at 16:29
  • dir \.* only returns .rnd (what this is, I don't know). If you want to see the files that start with a ., you need to use dir .*.*.
    – raven
    Apr 18, 2010 at 16:58
  • To clarify - the /s searches all subdirectories, but the /a-D excludes directory names beginning with dot. I'll edit the answer to make it clearer.
    – Mike
    Apr 19, 2010 at 1:39
3
filename:.*. -kind:folder

This finds all files which begin with a period, even those which do not have an extension. -kind:folder excludes folders from the search. Tested on Windows 7. Should work on Vista and Windows 8.

1

If you're willing to use a free 3rd party application, I highly suggest Locate32. You can search using regular expressions.

:^\. finds the files you are looking for. (You could also opt to exclude directories from results.) As a bonus, Locate32's index and search is much faster than the built-in Windows search. Plus the right-click context menu gives you some extra options like "Copy path to clipboard" and "Compute MD5."

I've created an AHK script so I can quickly bring up Locate32 with Win-F3.

3
  • Your image is broken. Do you happen to have the original that you could reupload? Thanks.
    – Gaff
    Sep 29, 2011 at 5:04
  • @Gareth: Dude, are you like some type of robot? I couldn't find the original image...
    – Leftium
    Sep 29, 2011 at 15:33
  • Great suggestion, just used this to find files matching ".-" without needing to use a regex. Also once files are found you can do the normal right-click operations e.g. delete.
    – RichVel
    Jun 10, 2015 at 15:20
1

Late addition ... I'm adding this as it comes in quite handy to set attributes from the command line for dot files (or directories) ...

The first dot is to search the current directory; the second is 'back-slashed escaped' to search for names starting with a dot literal.

dir ".\.*" /A 
1
  • The back slash is not a 'back-slashed escape' character. Rather it is a path separator which separates the first period, which is the path, from the second period, which is the initial part of the file name.
    – Itsme2003
    Jan 19, 2019 at 17:16
0

In Windows XP I was able to use Windows Explorer to search for .?* to see all files and folders that begin with a dot. Perhaps it works the same in Windows Vista and Windows 7.

Be careful, for me this returned files and folders, files and folders inside zip files, files and folders as seen in the Explorer Recycle Bin, and files and folders as seen in the Command Prompt RECYCLER folder. The search will likely also find files and folders as seen in other special folder views Explorer has.

1
  • Thanks for the suggestion, but I just tried this and it also seems to return all files and folders in Windows 7, not just those beginning with a period. Apr 18, 2010 at 19:59
0

To add to an earlier answer:

dir .*.* /s /a-D

This will also work:

dir .* /s /a-D

The difference being when you drop the trailing ".*" from the command, this finds files with or without an extension (i.e. the second dot before the extension).

Tested in Windows 7 & 10 using both commands produced the same results in my case because all files had extensions.


Note

When dealing with Mac resource forks you may want to narrow your search to files staring with "._"

dir ._*.* /s /a-D or dir ._* /s /a-D

That way "dot files" you want to keep like ".htaccess" and ".htpasswd" are excluded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.