2025-04-27 07:49:33 -04:00

52 lines
1.3 KiB
Plaintext

Oops. You FTP transferred files with an old 16-bit program.
Now all your files have all-caps names. This will be a
very BAD thing when you transfer them back to your
case-sensitive Unix machine. Changing the names back from
upper to lower case is something that needs QBASIC!
First, I write a batch file that will accept a filename
as an argument. It will run the QBASIC file (called
c:\temp\lower.bas in this example):
-----------------------------
if [%1]==[] goto START
goto RUNNING
:START
::If no arguments, change all files in the current directory
for %%x in (*.*) do call %0 %%x
goto DONE
:RUNNING
::change drives
%1\
::change directories
cd %1\..
set FileName=%1
qbasic /run c:\temp\lower.bas > temp.bat
call temp.bat
del temp.bat
:DONE
@echo off
cls
------------------------
Next I write the QBASIC file:
------------------------
FileName$ = ENVIRON$("FILENAME")
LowerName$ = ""
NextLetter% = LEN(FileName$)
NewLetter$ = MID$(FileName$, NextLetter%, 1)
if instr(FileName$, "\") = 0 then
LowerName$ = FileName$
else
DO WHILE NewLetter$ <> "\"
LowerName$ = NewLetter$ + LowerName$
NextLetter% = NextLetter% - 1
NewLetter$ = MID$(FileName$, NextLetter%, 1)
LOOP
endif
LowerName$ = LCASE$(LowerName$)
PRINT "ren " + FileName$ + " " + CHR$(34) + LowerName$ + CHR$(34)
SYSTEM