Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to rename files
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00832800
Message ID:
00834054
Views:
32
>>>>>That code snippet could be converted to VBScript, BTW.
>>>>
>>>>Ok, thanks, this is just what I just wrote in the other message. :)
>>>
>>>BTW, you might have to convert the Fox functions to public functions in the script file. While I know VB has several file parsing functions, I don't recall seeing them in the VBScript reference.
>>
>>This took me a while, but it works!
>>
>>'*******************************************
>>Vbscript:
>>'*******************************************
>>Option Explicit
>>Dim cJustName, cJustExt, cDtModified, cMonth, cDay
>>Dim oFSO, oFolder, oFile
>>
>>Set oFSO    = CREATEOBJECT("Scripting.FileSystemObject")
>>Set oFolder = oFSO.GetFolder( "C:\Temp\" )
>>
>>For Each oFile IN oFolder.Files
>>  cJustName   = oFSO.GetBaseName( oFile.Name )
>>  cJustExt    = oFSO.GetExtensionName( oFile.Name )
>>
>>  cMonth      = Right( "00" & Month( oFile.DateLastModified ), 2 )
>>  cDay        = Right( "00" & Day( oFile.DateLastModified ), 2 )
>>  cDtModified = Year( oFile.DateLastModified ) & cMonth & cDay
>>  oFile.Name  = cJustName & cDtModified & "." & cJustExt
>>Next
>>
>Andy,
>
>I think you're working to hard. Since VBScript references all variables as variants, you might be all to concatentate without explicitly converting it. However, even if you can't you could use the FormatDateTime() function.

I tried all the options for FormatDateTime( .DateLastModified ).
None returned a string in the format "YYMMDD" or "YYYYMMDD".
- Andy Rice
San Diego, CA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform