Copy FIle Names

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Set objFSO = CreateObject("Scripting.

FileSystemObject")

sInput = InputBox("Enter the folder path")


Set objFolder = objFSO.GetFolder(sInput)

Set colFiles = objFolder.Files

If Not objFSO.FolderExists("E:\selectedFileNames") Then


objFSO.CreateFolder("E:\selectedFileNames")
End If
outputFolder = "E:\selectedFileNames\fileNames"
For itr=1 to 10
If objFSO.FileExists(outputFolder&itr&".txt") Then
outFile=outputFolder&itr+1&".txt"
else
outFile=outputFolder&itr&".txt"
If NOT objFSO.FileExists(outputFolder&itr+1&".txt") Then
Exit for
End if
End If
Next

Set objFile1 = objFSO.CreateTextFile(outFile,True)

For Each objFile in colFiles


objFile1.WriteLine objFile.Name
Next

objFile1.Close
Set objFile1 = Nothing

You might also like