Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
StrToFile to create a batch file... Win98 & W2k differen
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00883093
Message ID:
00883109
Views:
11
This message has been marked as the solution to the initial question of the thread.
Hi Chris,

I'm using WSH to do the same (VFP8).
LPARAMETERS tcFileName, tcCase
LOCAL oFso, lcFileName, loFile, llOk, lcNewName
oFso = CreateObject("Scripting.FileSystemObject")
lcFileName = ALLTRIM(tcFileName)
llOk = .T.
TRY
	loFile = oFso.GetFile(lcFileName)
CATCH
	llOk = .F.
ENDTRY
IF llOk
	DO CASE
	CASE UPPER(tcCase) = "L"
		lcNewName = LOWER(loFile.Name)
	CASE UPPER(tcCase) = "U"
		lcNewName = UPPER(loFile.Name)
	CASE UPPER(tcCase) = "P"
		lcNewName = PROPER(loFile.Name)
	OTHERWISE
		llOk = .F.
	ENDCASE
	IF llOk
		TRY 
			loFile.Name = lcNewName + ".TEMP"
			loFile.Name = lcNewName
		CATCH
			llOk = .F.
		ENDTRY 
		IF llOk AND loFile.Name <> lcNewName
			llOk = .F.
		ENDIF	
	ENDIF	
ENDIF

RETURN llOk
>I am using the following to create a batch file whose purpose is to force jpg filenames to lowercase (for ftp'ing to a unix webserver):
>
>
>ERASE c:\lowercasenames.bat
>cPath = "C:\temp\"
>
>ADIR(aFiles,"c:\temp\*.JPG")
>IF TYPE("aFiles") = "C"
>  FOR nCnt = 1 TO ALEN(aFiles,1)
>    cText = "rename " + cPath + ALLTRIM(aFiles(nCnt,1)) +" " + LOWER(ALLTRIM(aFiles(nCnt,1)))+CHR(10)
>    STRTOFILE(cText,"C:\lowercasenames.bat",.t.)
>  ENDFOR
>ENDIF
>IF FILE("c:\lowercasenames.bat")
>   RUN /N7 C:\lowercasenames.bat
>ENDIF
>
>
>The batch file looks like:
>
>
>rename C:\temp\TEJAS1.JPG tejas1.jpg
>rename C:\temp\TEJAS2.JPG tejas2.jpg
>rename C:\temp\TEJAS3.JPG tejas3.jpg
>rename C:\temp\TEJAS4.JPG tejas4.jpg
>rename C:\temp\TEJAS5.JPG tejas5.jpg
>
>
>
>What you cant see in the bat file listing above is that there is a blank line at the end of the file... from the CHR(10).
>
>Running this batch file on a W2K box, it runs fine. Running it on a Win98 box, the last line is apparently a problem and no renaming takes place. I would think that each RENAME commandline is processed as it goes, but that does not appear to be the case. If i EDIT the bat file via the DOS prompt and remove the last line, save and run it, it runs fine. I am gunna strip out the last line, but why the difference between the different OS's?
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform