How can I export a directory structure in Windows?
Solution 1
Assuming your directory tree is of reasonable size, you could also use the built in tree
command, which produces a rather pretty looking directory tree. Unfortunately this prettiness is difficult to get working outside of a cmd instance, so you'll probably want to tell it to just use ascii characters with the /A
switch.
Example:
From a small multi-level structure
+---A
| +---A
| \---B
+---B
| \---A
| \---A
\---C
You can then redirect this to a file using a command like:
tree /A ["directory path"] > tree.txt
Where the directory path is optional, but useful if you want to tree something which isn't the current working directory.
Solution 2
If you want to use powershell the code is very simple and the output is nice.
Code:
Get-ChildItem | tree
With
Get-ChildItem | tree > foo.txt
you can pipe the output to a Textfile.
Example Output:
Auflistung der Ordnerpfade für Volume System
Volumeseriennummer : 48E9-F43B
C:.
├───Contacts
├───Desktop
├───Downloads
│ └───Evernote Import
├───Dropbox
│ ├───Apps
│ │ └───iftttcom
│ │ └───getpocketpdf
│ ├───Backup
│ ├───Camera Uploads
│ ├───Development
Solution 3
You can also put the results directly into the clipboard (in Vista+):
tree | clip
Solution 4
While you most likely want the output of the TREE
command (e.g. TREE /F > output.txt
) in this case, if raw text as the output is fine, then you can run the following from a command prompt:
DIR C:\ /S > output.txt
Where output.txt will be generated in the current working directory, and contain a listing of all files and directories on the C:
drive. If you want just an output of files with their full paths, run the following:
DIR C:\ /B /S > output.txt
It would also be a trivial task to write a program to parse the output back into a directory view style program for you to view.
Solution 5
Open command prompt window --> Go to your directory path
Then run the following command to generate
tree /f /a > tree.doc
Above command will make the folder and files structure recursively and export to word document file. You can find "tree.doc" created in the same folder
Related videos on Youtube
![johnw182](https://i.stack.imgur.com/smY8V.jpg?s=256&g=1)
johnw182
Updated on September 17, 2022Comments
-
johnw182 almost 2 years
I have a PreferenceFragment that loads preferences by calling addPreferencesFromResource(R.xml.preferences_main);
In side the preferences_main.xml file I have a custom preference called TimePreference which extends DialogPreference. TimePreference contains nothing but a TimePicker (have also tried DatePicker). When displayed the TimePicker is now a different format. Instead of being a spinner, it is the version with EditText views and up/down arrows. The real problem is those arrows are white and the text is white, all on a white background dialog.
If I put a TimePicker on an activity, it is the themed spinner style.
I cannot find out why this only happens on a DialogPreference and not on the activity. Its like it loses all styling.
My base theme is Theme.AppCompat.Light, I have tried a couple others with the same result.
Edit: My minSdkVersion is 11 and the target is 19
Anyone have any ideas?
public class TestPreference extends DialogPreference { Button btn; TimePicker tp; public TestPreference(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } @Override protected View onCreateDialogView() { tp = new TimePicker(getContext().getApplicationContext()); return tp; }
}
-
Admin about 13 yearsThis may help: How To Print A Directory Tree From Windows Explorer
-
Admin almost 13 yearsIf you want, I can write an AutoIt script to export the directory listing into plain-text in whatever style you would like. You could then write a program to parse it back into a directory-view like style.
-
Admin over 9 yearsRelated question at Stack Overflow.
-
-
xan almost 13 yearsYou can also pipe this output to a text file by doing:
tree E: \A \F > output.txt
-
UNK almost 13 years@xan; Whoops, that was the important bit of the answer and I completely forgot about it! Thanks
-
Breakthrough almost 13 years@xan just FYI, you need to use forward-slashes (
/
) instead of backslashes for command line argument identifiers. Backslashes are directory tree separators in Windows systems. -
Rick Methe over 10 yearsThere seems to be a (small) limit to how much this can print. It stops part way through my files.
-
johnw182 almost 10 yearsI was just trying that before eclipse crashed and it seemed to be working. I will let you know more in a few.
-
johnw182 almost 10 yearsAlso TestPreference is being created from the preferences xml so how can I pass my activity's reference to it?
-
waqaslam almost 10 yearsahh, then simply stick to what I said for initializing TimePicker.
-
johnw182 almost 10 yearswaqaslam, that was the solution... The style was still different that the norm and that was because the style in values-14 was different. I changed that style and got the expected layout. The issue with the font and arrows being white was resolved by removing the .getApplicationContext(). Thanks!
-
eddy almost 10 yearsThank you so much! You're a lifesaver. @waqaslam do you think you could help me here goo.gl/MAjgTh
-
Ulysses Alves over 7 yearsYou can also show the filenames below their parent folder on the tree structure by adding the
/f
option like this:tree /A /f ["directory path"] > tree.txt
-
Royi about 7 yearsCould one control the depth of the tree?
-
I say Reinstate Monica over 5 years@Royi I see you've posted several comments asking follow up questions. Please post your own question instead. Link back to this post to provide context if needed.
-
Royi over 4 yearsCan you limit it to folders name and limit the depth to 2?
-
Avsek over 4 yearsYes, you can.
Get-ChildItem -Recurse -Directory -Depth 2 'Z:\temp' | Select-Object -Property FullName,name | Export-Csv directory_structure.csv
-
Tolga about 4 yearsI'm afraid tree discards the input from the pipeline. For that reason your command is the same as running tree by itself, so it is pointless to pipe the output of Get-ChildItem to tree.
-
Grumpy ol' Bear almost 4 yearsCould someone build this pretty please? It does exactly what I want.
-
Anmol Singh Jaggi almost 4 years@Grumpyol'Bear If you want, I can port it to Python this weekend :)
-
Kamlesh over 3 yearsjust goto the directory you want to export in command line then enter this command: dir /b /s > exported_files.txt