Comment ========================================================== Computer Tyme LongSave * Copyright 1997 by Marc Perkel All Rights Reserved This program saves and restores long file names to a comma delimited ascii file. Computer Tyme * 411 North Sherman, Suite 300 * Springfield Mo. 65802 (800) 548-5353 Sales * (417) 866-1222 Voice * (417) 866-1665 Data/Fax ========================================================== EndComment ;#Define Shareware ;------ Create Variables Var FileMask StartDir StartDirLength RecurseDirectories RenameMode Files ShortName FullShortName LongName FullLongName OutFileName Out Quiet ChangeFileCase '.' ;Main ExitMenu ;======================= P R O C E D U R E S =========================== Procedure Pause var Ch if OutputRedirected then Return Write 'Press and Key ... ' Ch = ReadKey Write CR ' ' CR EndProc Procedure Help Var HelpText Include 'ADDRESS.INC' HelpText = Set[ LongSave is used to save the list of long file names and short names to a comma delimited ascii text file. The short names can then be backed up or zipped or copied with utilities that are not long file name aware. After the files are transfered LongSave can then use the ascii file to restore the original long file names. Price $95 per File Server. $25 for a workstation. Written in MarxMenu. Comes free with the Network Survival Kit. ] Loop HelpText Writeln LoopVal EndLoop Pause HelpText = Set[ To use LONGSAVE you have to tell it a directory to save and the name of a file to save the names to. If you don't specify a file name then the file LONGSAVE.ASC is created in the specified directory. By default LONGSAVE reads the long names in the specified directory and all directories below it. Usage: LONGSAVE /W Example: LONGSAVE C:\WINDOWS ; saves the names to ascii file LONGSAVE.ASC in C:\WINDOWS LONGSAVE . /W ; restores filenames in current directory from LONGSAVE.ASC LONGSAVE F:\WINDOWS SAVE.ASC /W ; restores long names in F:\WINDOWS from file SAVE.ASC ] Loop HelpText Writeln LoopVal EndLoop Pause HelpText = Set[ As of now LONGSAVE must be run from a DOS session under Windows 95. It will not run outside of Windows, although a future version of Windows might fix this. It also will not run under the original release of NT4, but I would hope Microsoft will fix this soon. It will work on NT4 servers from a Windows 95 workstation. It also works on Netware servers that are configured to support long file names. This is an early release. If it has any bugs let me know. If you find any interesting uses I haven't thought of for it or would like features added feel free to contact me. ] Loop HelpText Writeln LoopVal EndLoop ExitMenu EndProc #If Shareware Procedure Beg BoxBorderColor Green Blue BoxInsideColor White Blue BoxHeaderColor Yellow Mag BoxHeader ' * Shameless Beg Screen * ' DrawBox 10 8 61 6 Writeln WriteCenter '* LongSave Evaluation Copy *' Writeln WriteCenter 'Please remember to register this software.' Wait 600 EraseTopWindow ClearKbdBuffer EndProc #Endif Procedure Error ($St) Writeln Writeln 'Error: ' St ExitCode = 255 ExitMenu EndProc Procedure Setup var P O #If Shareware Beg #Endif StandardIO CmdLine = UpperCase(CmdLine) RecurseDirectories = not Optionswitch(CmdLine,'N') Quiet = Optionswitch(CmdLine,'Q') if not Quiet Writeln Writeln 'Computer Tyme LOWDIR * Copyright 1998 by Marc Perkel' Writeln 'All Rights Reserved * Version 1.0 * Release Date: 04-25-98' endif ExitCode = 0 if pos('/',CmdLine) > 0 then Help if ParamStr(2) = '' then Help if not LfnSupported Error 'This operating system does not support long name services from DOS.' endif StartDir = NextWord(CmdLine) if StartDir = '' then Help FileMask = FilePart(StartDir) StartDir = LfnShortName(PathPart(StartDir)) OutFileName = NextWord(CmdLine) if not ExistDir(StartDir) Error StartDir + " directory doesn't exist!" endif if LfnMaxNameLength(StartDir) <= 12 Error "The file system on " StartDir " doesn't support long names." endif if Outfilename = '' OutFileName = 'LONGSAVE.ASC' endif if pos('\',OutFileName) = 0 OutFileName = CleanFileName(StartDir + '\' + OutFileName) endif EndProc Procedure NameOnly (Name) var P P = Length(Name) while Mid(Name,P,1) <> '\' P = P - 1 endwhile Return Mid(Name,P+1,255) EndProc Procedure ChangeFileCase (Dir) var Scan Subs SaveDir SaveDir = CurrentDirectory ChDir Dir IncludeDirectories On DirectoriesOnly Off WholeFileNames Off Scan = CleanFileName(Dir + '\' + FileMask) if not Quiet Writeln 'Processing: ' Scan endif ReadDirectory(Scan,Files) Loop Files ShortName = LoopVal LongName = NameOnly(LfnLongName(ShortName)) FileRename LongName LowerCase(LongName) EndLoop Dispose(Files) ; if RecurseDirectories IncludeDirectories On DirectoriesOnly On WholeFileNames On ReadDirectory(Dir,Subs) Loop Subs ChangeFileCase(LoopVal) EndLoop Dispose(Subs) ; endif ChDir SaveDir EndProc Procedure ReadSubdirectories (Dir) var Subs Scan IncludeDirectories Off DirectoriesOnly Off WholeFileNames Off Scan = CleanFileName(Dir + '\' + FileMask) if not Quiet Writeln 'Processing: ' Scan endif ReadDirectory(Scan,Files) Loop Files ShortName = LoopVal FullShortName = Dir + '\' + ShortName FullLongName = LfnLongName(FullShortName) LongName = NameOnly(FullLongName) if LongName <> ShortName delete(FullShortName,1,StartDirLength) delete(FullLongName,1,StartDirLength) FileWriteln(Out,'"' FullShortName '","' LongName '"') endif EndLoop Dispose(Files) if RecurseDirectories IncludeDirectories On DirectoriesOnly On WholeFileNames On ReadDirectory(Dir,Subs) Loop Subs ReadSubdirectories(LoopVal) EndLoop Dispose(Subs) FullShortName = Dir FullLongName = LfnLongName(FullShortName) if FullLongName <> FullShortName delete(FullShortName,1,StartDirLength) delete(FullLongName,1,StartDirLength) while pos('\',FullLongName) > 0 delete(FullLongName,1,pos('\',FullLongName)) endwhile FileWriteln(Out,'"' FullShortName '","' FullLongName '"') endif endif EndProc Procedure SaveNames StartDirLength = length(StartDir) if StartDirLength = 3 Length(StartDir) = 2; else StartDirLength = StartDirLength + 1 endif if FileMask = '' FileMask = '*.*' endif if not Quiet Writeln Writeln 'Saving Long File Names' Writeln 'Creating file: ' OutFileName Writeln endif FileAssign(Out,OutFileName) FileCreate(Out) if FileResult <> 0 Error FileResult ' while creating file ' OutFileName endif ReadSubdirectories(StartDir) FileClose(Out) EndProc Procedure CopyPathPart (Old,New) var P P = Length(Old) while (Mid(Old,P,1) <> '\') and (P > 0) P = P - 1 endwhile delete(Old,P+1,255) Return Old + New EndProc Procedure AddLongNames var F A if not Quiet Writeln Writeln 'Restoring Long File Names' Writeln 'Opening file: ' OutFileName Writeln endif FileAssign(F,OutFileName) FileOpen(F) while not EndOfFile(F) ReadlnAsc(F,A) A[2] = CopyPathPart(A[1],A[2]) FileRename(A[1],A[2]) endwhile FileClose(F) EndProc Procedure Main Setup if RenameMode AddLongNames else SaveNames endif if not Quiet Writeln Writeln 'Done!' endif EndProc