How to save file structure to text file?

我是研究僧i 提交于 2019-12-19 10:09:02

问题


I have a folder of media files that are about 1TB big. I want to save the file names and directory structure to a text file for backup and reference. I want to attach a batch or PowerShell script to my backup process so the file gets saved before the backup. Does anyone know an easy way to do this?


回答1:


You can use the built in tree.com utility:

tree c:\folder /F

There's also a PowerShell function, Show-Tree, in PSCX 2.0:

http://rkeithhill.wordpress.com/2010/05/10/pscx-2-0-show-tree/




回答2:


a pure dir solution

dir /b /s c:\folder >foldertree.txt

has the advantages over Shay and mjolinor solutions that

  1. it does not require powershell, just a plain cmd command
  2. the result list contains the fully specified filenames which is a better format for postprocessing of any kind.



回答3:


To just save the directory structure and file names:

get-childitem <dir> -recurse | select -expand fullname > dirtree.txt



回答4:


Open powershell in the folder then run this to show the files tree in your powershell:

tree /a /f

or save it as txt file:

tree /a /f > tree.txt


来源:https://stackoverflow.com/questions/9569896/how-to-save-file-structure-to-text-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!