Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getfolderitem(folder, byref root)
- dim fo, fi
- root = false
- set fo = folder.parentfolder
- set fi = fo.parsename(folder.title)
- if fi is nothing then
- for each fi in fo.items
- if fi.name = folder.title then
- root = true
- set getfolderitem = fi
- exit function
- end if
- next
- set getfolderitem = nothing
- else
- set getfolderitem = fi
- end if
- end function
- function itempath(fi)
- dim path, fitm, root
- if instr(fi.path, "~") > 0 then
- set fitm = fi
- path = fitm.name
- do
- root = false
- set fitm = getfolderitem(fitm.parent, root)
- if fitm is nothing then exit do
- if root then
- path = fitm.path & path
- exit do
- else
- path = fitm.name & "\" & path
- end if
- loop
- itempath = path
- else
- itempath = fi.path
- end if
- end function
- sub check(path)
- dim fo, fi
- on error resume next
- set fo = sa.namespace(path)
- if err.number = 0 then
- for each fi in fo.items
- path = itempath(fi)
- if len(path) > 259 then
- if gui then
- txt = txt & path & vbcrlf
- else
- wscript.echo path
- end if
- else
- if fi.isfolder then check(fi.path)
- end if
- next
- elseif gui then
- txt = txt & path & vbcrlf
- else
- wscript.echo path
- end if
- on error goto 0
- end sub
- set sh = createobject("wscript.shell")
- set fs = createobject("scripting.filesystemobject")
- set sa = createobject("shell.application")
- if wscript.arguments.count = 0 then
- wscript.echo "FindLongPaths {RootPath}"
- wscript.quit
- end if
- gui = instrrev(lcase(wscript.fullname), "\wscript.exe") > 0
- txt = ""
- check(wscript.arguments(0))
- if gui then
- if txt <> "" then
- fn = sh.specialfolders("desktop") & "\Long Paths " & _
- replace(replace(now, "/", "-"), ":", ".") & ".txt"
- set f = fs.createtextfile(fn, true, true)
- f.write(txt)
- f.close
- sh.run """" & fn & """", 1
- else
- wscript.echo "No long path found."
- end if
- end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement