Metspitzer said:
Write me a batch file please?
I have two folders with videos. I would like a batch file that prints
the filenames (with or without extension) to a text file and then
sorts the list.
Copy the following into Notepad, and save as "listdir.vbs".
***********************************************************
' // Script to list files.
' // List is tab separated.
' // Based on someone elses script, with slight changes.
' // Output looks like this. (Size <tab> Date <tab> Path)
' //
' // 32964 1/19/2012 1:06:32 AM C:\test.txt
' //
' // This program has no command line arguments. You enter the
' // topDir as a string in the line below. That's where it'll start
' // scanning. The output always goes to ScriptOutput1.txt . Change
' // the name to something you like.
' //
' // Program has no error handling. I just changed another script, to make this one.
' //
' // In the Command Prompt window, enter "listdir" as the command...
' // listdir.vbs should be in your current working directory, do the DOS shell
' // can find it.
Dim objFSO
Dim tab
tab=chr(9)
topDir = "C:\Downloads\"
set objFSO = CreateObject("Scripting.FileSystemObject")
' Create text file to store output data
' When you launch this in MSDOS window, file will be created in current working directory.
Set OutputFile = objFSO.CreateTextFile("ScriptOutput1.txt", True)
Set objFolder = objFSO.GetFolder(topDir)
Set colFiles = objFolder.Files
Set colFolders = objFolder.SubFolders
For Each objFile in colFiles
Outputfile.write(objFile.size)
Outputfile.write(tab)
Outputfile.write(objFile.DateLastModified)
Outputfile.write(tab)
Outputfile.writeLine(objFile.Path)
Next
' Call a separate subroutine, to output file contents of subfolders
For Each objSubFolder In colFolders
ScanSubFolders(objSubFolder)
Next
' Close text file
OutputFile.Close
' Program ends here...
' // **************************************
Sub scanSubFolders(objFolder)
Set colFiles = objFolder.Files
Set colFolders = objFolder.SubFolders
For Each objFile in colFiles
Outputfile.write(objFile.size)
Outputfile.write(tab)
Outputfile.write(objFile.DateLastModified)
Outputfile.write(tab)
Outputfile.writeLine(objFile.Path)
Next
For Each objSubFolder In colFolders
ScanSubFolders(objSubFolder)
Next
End Sub
***********************************************************
The output from the script, is tab separated. Import the
text file created from the script, with a spreadsheet
program, and you can do the sorting from there. The tab
separated format, is intended to make it easier to import
into a spreadsheet.
HTH,
Paul