mskadu (owner)

Revisions

gist: 23943 Download_button fork
public
Description:
Converts Long file/pathname to Short (or 8.3) format
Public Clone URL: git://gist.github.com/23943.git
Embed All Files: show embed
longtoshort.vbs #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'-----------------------------------------------------------------------------------
' Donated to open source - feel free to use, copy, modify, etc
'-----------------------------------------------------------------------------------
'
'Script to convert a long path or filename into it's 8.3 equivalent.
'For copy-pasting convenience, it pops up a box with the result
'
'Note:
' Please make sure that long names especially those containing spaces
' should be enclosed in double quotes. Eg. "c:\this is a long folder name"
'
'Usage:
' wscript longtoshort.vbs {filename or pathname}
'
'Example
' wscript.exe longtoshort.vbs "c:\Documents and Settings\All Users"
' wscript.exe longtoshort.vbs "c:\Documents and Settings\All Users\desktop\sample.txt"
' wscript.exe longtoshort.vbs c:\sample.txt
'
 
Set fso=CreateObject("Scripting.FileSystemObject")
 
'Check for arguments
set oArgs = Wscript.Arguments
if oArgs.count=0 then
  wscript.echo "No argument given"
  wscript.quit
end if
 
' Is object a file or folder?
If fso.FolderExists(WScript.Arguments(0)) Then
  'It's a folder
  Set objFolder = fso.GetFolder(WScript.Arguments(0))
  rtrn = InputBox("Here's your short path:", "SHORT PATH", objFolder.ShortPath)
End If
 
If fso.FileExists(WScript.Arguments(0)) Then
  'It's a file
  Set objFile = fso.GetFile(WScript.Arguments(0))
  rtrn = InputBox("Here's your short filename:", "SHORT PATH", objFile.ShortPath)
End If