Friday, February 17, 2012

Make a file list quickly

Need to write a bunch of filenames to a list (say to build a resources list for a Grails plugin or html page) because you can't include just folders? But you don't want to type them all out individually?

Open that good old standby, cmd.exe  or terminal and navigate to the root folder containing the files.

[Windows] command: DIR *.* /s /b > ../yourlistname.LST

[Linux/OSX] command:  find * . > yourlistname


You can easily add extensions to the DIR and find commands to find only a particular kind of file (DIR *.js for example) Open in your favorite text editor (why not try notepad++ or textmate) use some regex-replacing..


Lets try removing directories from the file list (this could also be done with additional filters in the find commands above):



  • In notepad++, turn on regular expression searching, and check 'mark line'
  • Search for [\w+][\.][\w+], which will bring up every line with a . in it (a valid extension)
  • Invert the bookmarking with Search->Bookmark->Inverse Bookmark
  • Finally delete the now bookmarked lines without file extensions by Search->Bookmark->Delete Bookmarked Lines



And your done.

No comments:

Post a Comment