Have you ever want a quick way to make a clone of a file in the same folder or copy file names to Microsoft Windows clipboard. This script creates context-shell menu shortcuts for all files that will provides the folloing functions.

Now available as a fast, compiled shell extension. Download FileShellControl (exe file)

Download FileShellControl (vbs file)

  1. ' ********************************************************* ' FILE: FileShellControl.vbs ' VERSION: 1.2.1 ' CREATED: 5/25/2004 ' UPDATED: 6/11/2004 ' AUTHOR: Scott Greenberg ' Company: SG Technology ' Website: http://gogogadgetscott.info ' DECRIPTION: Perform serval file operations including, ' creating a clone of file With a New filename prefix (Copy of * _), ' copy file name To clipboard, copy file path To clipboard. ' Add sortcuts To context shell menu. ' File name passed As an argument. ' COMMENT: Requires Microsoft internet Explorer 5+ ' CHANGE Log : ' 1.2.1: 06/11/2004 - Fixed duplicate file extensions '   1.2: 06/11/2004 - Fixed GetLongFileName To allow periods, (.) In folder name '   1.1: 06/01/2004 - Update GetLongFileName To Return full path In Long format ' To Do : '    N/A ' Copyright© 2004. SG Technology. All rights reserved. ' ********************************************************* sCloneFilePrefix = "Copy of " Set FS = CreateObject ("Scripting.FileSystemObject") Set WShell = CreateObject ("WScript.Shell") Set args = WScript.Arguments sRegPath = "HKCR\*\shell\" ' Comment out any undesired Option here AddReg sRegPath & "Clone\", "Create a C&lone", "a" AddReg sRegPath & "CopyFilepath\", "Copy File P&ath", "b" AddReg sRegPath & "CopyFilename\", "Copy File Na&me", "c" ' Get command line aguments If args.Count = 0 Then DisplayHelp "" sPath = args(0) action = args(1) If FS.FileExists(sPath) Then   ' Convert short To Long path   sLongPath = GetLongFileName(sPath)   'MsgBox sLongPath   'WScript.Quit   ' Create New clone path   sFileName = FS.GetFileName(sLongPath)   sNewPath = FS.GetParentFolderName(sLongPath) & "\" & _     sCloneFilePrefix & sFileName Select Case action Case "-a"   FS.CopyFile sLongPath, sNewPath Case "-b"   ClipCopy sLongPath Case "-c"   ClipCopy sFileName Case "-d"   ClipCopy sFileName   End Select Else DisplayHelp "Invalid filename." End If ' Add registy entry To create file context shell item Sub AddReg(sRegPath, sName, ArgValue)   On Error Resume Next   WShell.RegRead (sRegPath)   If Err.number <> 0 Then    WShell.RegWrite sRegPath, sName    sData = "wscript """ & WScript.ScriptFullName & _      """ ""%1"" -" & ArgValue    WShell.RegWrite sRegPath & "command\", sData   End If   On Error GoTo 0 End Sub ' Copy String To clipboard Sub ClipCopy(sText)   On Error Resume Next With CreateObject ("InternetExplorer.Application") .Navigate "about:blank" Do Until .ReadyState = 4 WScript.Sleep 50 Loop With .document.ParentWindow.ClipboardData .SetData "text", sText End With ' ClipboardData End With ' IE End Sub ' Get Long File/Path Name, using winmgmts ' requred becouse argument passed Is In short 8.3 format Function GetLongFileName(sPath)   ' Query requires path format w/ "\\" i.e. C:\\windows\\win.ini   sShortPath = Replace (sPath, "\", "\\")   ' Get Long folder name, one at a time   aPathParts = Split (sShortPath, "\\")   sLongPath = aPathParts(0)   For i = 1 To UBound (aPathParts)     sTmpPath = sLongPath & "\\" & aPathParts(i)     sQuery = "Select FileName, Extension from Win32_Directory where Name = '" & _       sTmpPath & "'"     Set FolderSet = GetObject ("winmgmts:").ExecQuery(sQuery)     For Each oFolder In FolderSet       sLongPath = sLongPath & "\\" & oFolder.FileName       If oFolder.Extension <> "" Then         sLongPath = sLongPath & "." & oFolder.Extension       End If     Next   Next   ' Get Long file name   sQuery = "Select FileName, Extension from CIM_DataFile where Name = '" & _     sShortPath & "'"   Set FileSet = GetObject ("winmgmts:").ExecQuery(sQuery)   For Each oFile In FileSet     sFullFileName = oFile.FileName & "." & oFile.Extension   Next   GetLongFileName = Replace (sLongPath & "\" & sFullFileName, "\\", "\") End Function ' Display help infomation Sub DisplayHelp(msg) m_msg = "About this script:" & Chr (13) If msg <> "" Then m_msg = m_msg & msg & Chr (13) m_msg = m_msg & " [-a | -b | -c] < file >" & Chr (13) & Chr (13) m_msg = m_msg & " -a Create a File Clone." & Chr (13) m_msg = m_msg & " -b Copy a File Path To Clipboard." & Chr (13) m_msg = m_msg & " -c Copy a File Name To Clipboard." & Chr (13) MsgBox m_msg WScript.Quit - 1 End Sub

Download FileShellControl (vbs file)