program ren_file; { Program that converts filenames to lowercase } uses dos; const name = 'Ren_file ver 2.0a - www.hjelmenet.dk/software'; err : boolean = false; var s, sl: shortstring; f : file; const ok : word = 0; rn : word = 0; procedure start(startname:shortstring); var srec : searchrec; begin findfirst(startname+'*.*',$3f,srec); while (doserror=0) do begin if srec.name[1]<>'.' then begin if srec.attr=16 then start(startname+srec.name+'/'); sl:=lowercase(srec.name); if sl<>srec.name then begin writeln(startname+srec.name,' -> ',startname+sl); assign(f,startname+srec.name); {$i-} rename(f,startname+sl); {$i+} if ioresult>0 then begin writeln(^G,'Rename error: ',startname+srec.name,^G); err:=true; end; inc(rn); end; inc(ok); end; findnext(srec); end; end; begin { ===================== MAIN ======================= } writeln(name); s:=paramstr(1); if boolean(pos('\',s)) then begin while s[length(s)]<>'\' do delete(s,length(s),1); delete(s,length(s),1); chdir(s); writeln('Directory changed to : '+s); end; if boolean(pos('?',paramstr(1))) then begin writeln; writeln('Ren_file is written for Freepascal (www.freepascal.org) and can be compiled'); writeln('into either Win95 or Linux.'); writeln; writeln('Ren_file will start from the current directory and will recursively attempt'); writeln('to rename all subdirectories and files to lowercase names.'); writeln; writeln('The programme will not accept any parameters except -? printing this help.'); writeln; writeln('The programme is freeware and is supplied as is, without any warranty at all.'); writeln; writeln('Feedback is much appreciated. erik@hjelmenet.dk http://www.hjelmenet.dk'); halt(1); end; start(''); writeln(rn,' of ',ok,' files uppercase'); if err then begin writeln('Error(s) encounted, hit to terminate program.'); readln; halt(1); end;end.