Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys!

I try to list all the file in my PC and network drive with this condition:

1. The full path character is exceeding 255 character
2. The output saved in a .txt file

How can I do it?

FYI, I never created a batch file before. Thanks in advance.
Posted
Comments
RDBurmon 25-Feb-13 12:31pm    
What does it mean "The full path character is exceeding 255 character" ?

1 solution

Again, I manage to figure out the solution by myself. But I use both batch and vbscript file in order to make this work.

For batch file, write this code and save is as [any name].bat

SQL
@echo Please wait untill this window closed :P
@echo off
for /r %%a in (*) do echo %%a >> file_list.txt


For vbscript file, write this code and save is as [any name].vbs

Wscript.Echo "Please wait..."
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFS.OpenTextFile("C:\Documents and Settings\FIRDHAUS\Desktop\file_list.txt")
Set objFS1 = objFS.CreateTextFile("C:\Documents and Settings\FIRDHAUS\Desktop\file_list_temp.txt",true)
objFS1.close
set objTextFile2 = objFS.OpenTextFile("C:\Documents and Settings\FIRDHAUS\Desktop\file_list_temp.txt",8)
strFile = "C:\Documents and Settings\FIRDHAUS\Desktop\file_list.txt"

Do Until objTextFile.AtEndOfStream
    strLine = objTextFile.ReadLine
    If Len(strLine) > 60 Then
        strLine = Replace(strLine,"",1)
      Else
	objTextFile2.writeline strLine
    End If
   
Loop

Set objTextFile = nothing
Set objTextFile2 = nothing

objFS.copyFile "C:\Documents and Settings\FIRDHAUS\Desktop\file_list_temp.txt", "C:\Documents and Settings\FIRDHAUS\Desktop\file_list.txt", true
objfs.DeleteFile "C:\Documents and Settings\FIRDHAUS\Desktop\file_list_temp.txt"

Set objfs = nothing
Set objfs1 = nothing
Wscript.Echo "Done :)"


Noted that in the vbscript, the path for txt file is not fixed. You have to change it depend on the location of your .txt file.

Copy and paste .bat file into the any root folder that you want and you will get .txt file with numerous list of files with full path :)

Good Luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900