From: Kenneth A. Larsen on 27 Jul 2010 19:22 "Oleg" <Oleg(a)discussions.microsoft.com> wrote in message news:DA63C844-D044-437C-92FD-3C395C7E02DC(a)microsoft.com... > Thanks, that works !:) I didnt know the code that told the script to > actually > do the job, now its clear. > However, it runs into the problem when 2 files have the identical > timestamp, > then the script terminates with an error. > Is it possible to use fso.MoveFile for the collection of files? So that > the > script first renames and moves file to the destination folder, then > processes > another. > Sorry for the newby questions, im pretty new to VBScript... > > Oleg > > "Dave "Crash" Dummy" wrote: > >> Oleg wrote: >> > Can someone tell if its possible to replace the basename of a number >> > of .jpg files in specified folder to match their date stamp? >> > file.DateCreated can see that date, but how can I actually rename the >> > files? Thanks! >> >> The script below will do what you want. I recommend using >> DateLastModified instead of DateCreated. That is what is displayed in >> Explorer. The DateCreated changes every time the file is copied. >> >> The date-time string contains illegal characters for a filename (/,:), so >> those have to be replaced. Another possible trouble spot, one that is >> not dealt with in this script, is two files having the same date-time. >> >> '=================rename.vbs================ >> set fso=CreateObject("Scripting.FileSystemObject") >> set objFolder=fso.getFolder("d:\pics") >> >> for each file in objFolder.files >> filename=LCase(file.name) >> if right(filename,4)=".jpg" then >> newname=file.dateLastModified >> newname=replace(newname,"/","-") >> newname=replace(newname,":","-") >> file.name=newname & ".jpg" >> end if >> next >> '========================================= >> -- >> Crash >> >> "Something there is that doesn't love a wall, that wants it down." >> ~ Robert Frost ~ >> . >>You're welcome!
|
Pages: 1 Prev: VB Script Errors in Working Scripts Next: VBScript for writing in the command prompt |