Posts: 43
Threads: 19
Joined: Feb 2015
Reputation:
0
07-02-2016, 04:33 AM
(This post was last modified: 07-02-2016, 12:42 PM by Britec.)
Hey guys I have been looking all day to find a command which will list all files on a drive including files in sub folders and save the list to a file.
I create a .bat file from notepad with these instructions and run the bat file from the root of the drive which contains the files and sub folders.
dir /b /s /a:-d >list.txt
I get a file called list.txt with entries like this
E:\New Movies\The file test.mp4
But I would like to just have it list like this
The file test.mp4
I dont need to know the directories, file only. and for some reason when run on an external hard drive It picks up the recycled folder like this,
E:\$RECYCLE.BIN\S-1-5-21-2095992690-2580178275-4034271705-1001\$I3EZY6W.avi
I want to scrub that out as well.
Cheers for any help.
Posts: 4,727
Threads: 311
Joined: Sep 2014
Reputation:
102
07-02-2016, 12:42 PM
(This post was last modified: 07-02-2016, 12:43 PM by Britec.)
Try this:
- Copy all code below.
- Paste to notepad and Create a vbs file ie: list.vbs
- Change directory location GetFiles("YOUR LOCATION") to wherever you want. Example: GetFiles("E:\Downloads")
- Right Click list.vbs and open in command prompt
- It will create a OutputFiles.csv in the directory you run list.vbs
Code:
Dim fso
Dim ObjOutFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set ObjOutFile = fso.CreateTextFile("OutputFiles.csv")
ObjOutFile.WriteLine("Type,File Name,File Path")
GetFiles("YOUR LOCATION")
ObjOutFile.Close
WScript.Echo("Completed")
Function GetFiles(FolderName)
On Error Resume Next
Dim ObjFolder
Dim ObjSubFolders
Dim ObjSubFolder
Dim ObjFiles
Dim ObjFile
Set ObjFolder = fso.GetFolder(FolderName)
Set ObjFiles = ObjFolder.Files
For Each ObjFile In ObjFiles
ObjOutFile.WriteLine("File," & ObjFile.Name & "," & ObjFile.Path)
Next
Set ObjSubFolders = ObjFolder.SubFolders
For Each ObjFolder In ObjSubFolders
ObjOutFile.WriteLine("Folder," & ObjFolder.Name & "," & ObjFolder.Path)
GetFiles(ObjFolder.Path)
Next
End Function
<left><form action="https://www.paypal.com/cgi-bin/webscr" method="post">If you are satisfied with my help, consider a donation. Thank you so much for your continued support!
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="Y4ZDLXGFS4F8Q">
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="0" height="0">
</form>
</div></left>
Posts: 4,727
Threads: 311
Joined: Sep 2014
Reputation:
102
Yeah it works
<left><form action="https://www.paypal.com/cgi-bin/webscr" method="post">If you are satisfied with my help, consider a donation. Thank you so much for your continued support!
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="Y4ZDLXGFS4F8Q">
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="0" height="0">
</form>
</div></left>
Posts: 4,727
Threads: 311
Joined: Sep 2014
Reputation:
102
Nah not with that script, glad it works for you.
<left><form action="https://www.paypal.com/cgi-bin/webscr" method="post">If you are satisfied with my help, consider a donation. Thank you so much for your continued support!
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="Y4ZDLXGFS4F8Q">
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="0" height="0">
</form>
</div></left>