bsharath
asked on
Find filenames or folder names that have more than 256 characters and list them into a txt file with the path.
Hi,
Find filenames or folder names that have more than 256 characters and list them into a txt file with the path.
So i can see them and later browse to the path and delete some words.
Regards
Sharath
Find filenames or folder names that have more than 256 characters and list them into a txt file with the path.
So i can see them and later browse to the path and delete some words.
Regards
Sharath
Lets try that again.
Set ofso = CreateObject("Scripting.Fi leSystemOb ject")
Set obshell = CreateObject("Wscript.shel l")
Set path = ofso.GetFolder(obshell.Cur rentDirect ory)
Set txtfile = ofso.CreateTextFile("Files .txt",1)
Set obfolder = path.Files
For Each file In obfolder
strlen = Len(fine.name)
If strlen = 256 Then
If file.Name <> "File List.vbs" Then
txtfile.writeline file.Name
End If
End If
Next
txtfile.close
Set ofso = CreateObject("Scripting.Fi
Set obshell = CreateObject("Wscript.shel
Set path = ofso.GetFolder(obshell.Cur
Set txtfile = ofso.CreateTextFile("Files
Set obfolder = path.Files
For Each file In obfolder
strlen = Len(fine.name)
If strlen = 256 Then
If file.Name <> "File List.vbs" Then
txtfile.writeline file.Name
End If
End If
Next
txtfile.close
ASKER
I tried the 2nd script
I get this
-------------------------- -
Windows Script Host
-------------------------- -
Script: D:\Morethan256.vbs
Line: 9
Char: 7
Error: Object required: 'fine'
Code: 800A01A8
Source: Microsoft VBScript runtime error
-------------------------- -
OK
-------------------------- -
Where should i mention the path to let it scan
I get this
--------------------------
Windows Script Host
--------------------------
Script: D:\Morethan256.vbs
Line: 9
Char: 7
Error: Object required: 'fine'
Code: 800A01A8
Source: Microsoft VBScript runtime error
--------------------------
OK
--------------------------
Where should i mention the path to let it scan
Last folder/file in each line is greater than 256 in length.
Const ForWriting = 2
StartFolder = "C:\Files"
LogFile = "C:\256Length.log"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile(LogFile, ForWriting, True)
Call CheckFolder(StartFolder)
Set objFSO = Nothing
objLogFile.Close
Sub CheckFolder(Folder)
Set ArrFiles = objFSO.GetFolder(Folder).Files
For Each File In ArrFiles
IF Len(File.name) > 256 THEN objLogFile.WriteLine File
Next
IF Len(Folder) - instrrev(Folder,"\") > 256 THEN objLogFile.WriteLine Folder
Set ArrSubFolders = objFSO.GetFolder(Folder).SubFolders
For Each SubFolder In ArrSubFolders
call CheckFolder(SubFolder)
Next
End Sub
Yeah I type fine instead of file on the one line and you'll need to change it so the it's >= instead of just equal. Just drop it in a folder and run it and a text file will appear in that folder.
ASKER
AT i tried with some long named files. But none came into the log
This one will work, just drop in the directory and run it.
Set ofso = CreateObject("Scripting.Fi leSystemOb ject")
Set obshell = CreateObject("Wscript.shel l")
Set path = ofso.GetFolder(obshell.Cur rentDirect ory)
Set txtfile = ofso.CreateTextFile("Files .txt",1)
Set obfolder = path.Files
For Each file In obfolder
strlen = Len(file.name)
If strlen >= 256 Then
If file.Name <> "File List.vbs" Then
txtfile.writeline file.Name
End If
End If
Next
txtfile.close
Set ofso = CreateObject("Scripting.Fi
Set obshell = CreateObject("Wscript.shel
Set path = ofso.GetFolder(obshell.Cur
Set txtfile = ofso.CreateTextFile("Files
Set obfolder = path.Files
For Each file In obfolder
strlen = Len(file.name)
If strlen >= 256 Then
If file.Name <> "File List.vbs" Then
txtfile.writeline file.Name
End If
End If
Next
txtfile.close
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The actual limitation for full path as I remember it is 260 characters.
ASKER
THANK U AT worked fine
OrbitMed i dont know why when i moved any folder on the script it creates the txt file but no data gets logged. I even noticed that there is no process running when the script runs...
Any ways thanks for the help
OrbitMed i dont know why when i moved any folder on the script it creates the txt file but no data gets logged. I even noticed that there is no process running when the script runs...
Any ways thanks for the help
ASKER
THANK U AT worked fine
OrbitMed i dont know why when i moved any folder on the script it creates the txt file but no data gets logged. I even noticed that there is no process running when the script runs...
Any ways thanks for the help
OrbitMed i dont know why when i moved any folder on the script it creates the txt file but no data gets logged. I even noticed that there is no process running when the script runs...
Any ways thanks for the help
If you wanted full path greater than 256.
Const ForWriting = 2
StartFolder = "C:\Files"
LogFile = "C:\256Length.log"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile(LogFile, ForWriting, True)
Call CheckFolder(StartFolder)
Set objFSO = Nothing
objLogFile.Close
Sub CheckFolder(Folder)
Set ArrFiles = objFSO.GetFolder(Folder).Files
For Each File In ArrFiles
IF Len(File) > 256 THEN objLogFile.WriteLine File
Next
IF Len(Folder) > 256 THEN objLogFile.WriteLine Folder
Set ArrSubFolders = objFSO.GetFolder(Folder).SubFolders
For Each SubFolder In ArrSubFolders
call CheckFolder(SubFolder)
Next
End Sub
ASKER
AT what is the difference betwen the accepted solution and the solution u posted now
It checks for full paths greater than 256 characters.
C:\Folder1\Folder2\Folder3 \Folder4\W hatever filename which maybe super long.txt
I thought you wanted to shorten long lengths because of this potential error with Path lengths greater than 260 characters:
http://support.microsoft.com/kb/816841/en-us
http://support.microsoft.com/kb/883721/en-us
C:\Folder1\Folder2\Folder3
I thought you wanted to shorten long lengths because of this potential error with Path lengths greater than 260 characters:
http://support.microsoft.com/kb/816841/en-us
http://support.microsoft.com/kb/883721/en-us
ASKER
The accepted solution in this post will this find the filename or folder name that is longer than 256?
ASKER
The accepted solution in this post will this find the filename or folder name that is longer than 256?
The accepted solution is actually each filename or folder name greater than 25 characters. I put that for you to try and see if are getting anything into the log. 256 characters for just 1 filename or 1 folder name is rare. IE Favorites could have many of these but even they don't have that much.
ASKER
ok THX
ASKER
ok THX
Find filenames or folder names that have more than 256 characters ...
I have been trying your script but have errors can you help?
I have been trying your script but have errors can you help?
Set ofso = CreateObject("Scripting.Fi
Set obshell = CreateObject("Wscript.shel
Set path = ofso.GetFolder(obshell.Cur
Set txtfile = ofso.CreateTextFile("Files
Set obfolder = path.Files
For Each file In obfolder
If file.Name <> "File List.vbs" Then
txtfile.writeline file.Name
End If
Next
txtfile.close