Rename files to match date stamp

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!
0
Utf
6/4/2010 5:56:23 AM
scripting.vbscript 564 articles. 0 followers. Follow

18 Replies
1205 Views

Similar Articles

[PageSpeed] 39


"Oleg" <Oleg@discussions.microsoft.com> wrote in message 
news:F7853854-F72F-4EB3-8899-E6D670BE6545@microsoft.com...
> 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!

Yes, it is possible. Create an object oFile by using the GetFile method of 
the File System Object, then specify a new name via its .Name property. You 
will find full details plus examples in the downloadable help file 
script56.chm. 

0
Pegasus
6/4/2010 6:04:46 AM
Thanks for the feedback, i'll go through the file and try to put together all 
the pieces...Another thing is that the extension differs in case, some appear 
as upper, some as lower, i have no idea how to tell the script to use both...




"Pegasus [MVP]" wrote:

> 
> 
> "Oleg" <Oleg@discussions.microsoft.com> wrote in message 
> news:F7853854-F72F-4EB3-8899-E6D670BE6545@microsoft.com...
> > 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!
> 
> Yes, it is possible. Create an object oFile by using the GetFile method of 
> the File System Object, then specify a new name via its .Name property. You 
> will find full details plus examples in the downloadable help file 
> script56.chm. 
> 
> .
> 
0
Utf
6/4/2010 8:41:56 PM
Thanks for the feedback, i'll go through the file and try to put together all 
the pieces...Another thing is that the extension differs in case, some appear 
as upper, some as lower, i have no idea how to tell the script to use both...

"Pegasus [MVP]" wrote:

> 
> 
> "Oleg" <Oleg@discussions.microsoft.com> wrote in message 
> news:F7853854-F72F-4EB3-8899-E6D670BE6545@microsoft.com...
> > 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!
> 
> Yes, it is possible. Create an object oFile by using the GetFile method of 
> the File System Object, then specify a new name via its .Name property. You 
> will find full details plus examples in the downloadable help file 
> script56.chm. 
> 
> .
> 
0
Utf
6/4/2010 8:42:01 PM

"Oleg" <Oleg@discussions.microsoft.com> wrote in message 
news:86B69D88-2CFF-4183-8EB2-EBC65896DA71@microsoft.com...
> Thanks for the feedback, i'll go through the file and try to put together 
> all
> the pieces...Another thing is that the extension differs in case, some 
> appear
> as upper, some as lower, i have no idea how to tell the script to use 
> both...
>

When unsure about the case of a string, translate it to lower case, e.g. 
like so:

sExt = ".jpg"
if LCase(right(oFile.Name, 4)) = sExt then . . . 

0
Pegasus
6/4/2010 9:36:41 PM
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 ~
0
Dave
6/5/2010 11:31:25 AM
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 ~
> .
> 
0
Utf
6/5/2010 6:53:04 PM
"Dave "Crash" Dummy" <invalid@invalid.invalid> wrote in message 
news:cAqOn.91072$rE4.32891@newsfe15.iad...
> 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 ~

The OP's question was "Can someone tell if its possible to replace the 
basename of a number of .jpg files in specified folder to match their date 
stamp?". Your comprehensive reply reminds me of the saying "Give a man a 
fish; you have fed him for today. Teach a man to fish; and you have fed him 
for a lifetime". 


0
James
6/5/2010 7:17:15 PM
Moving the file before renaming it would mitigate the problem but not 
eliminate it. To really eliminate it you need to expand the file name with a 
numerical suffix that you keep increasing until it becomes unique. A better 
alternative would be not to rename the file but to add the date stamp to the 
existing file name. In this way you would not get any duplicate names at 
all.

"Oleg" <Oleg@discussions.microsoft.com> wrote in message 
news:DA63C844-D044-437C-92FD-3C395C7E02DC@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 ~
>> .
>> 
0
Pegasus
6/5/2010 7:52:56 PM
Oleg wrote:
> 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.

Pegasus' second suggestion, appending the date-time string to the
original name, is the simplest. His first suggestion, adding a numerical
suffix, can be implemented using a dictionary object. The reworked
script below does that.

'=================rename.vbs================
set fso=CreateObject("Scripting.FileSystemObject")
set objFolder=fso.getFolder("e:\pics")

Set d=CreateObject("Scripting.Dictionary")

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,":","-")
	if d.Exists(newname) then
		d.Item(newname)=d.Item(newname)+1
	else
		d.Add newname,1
	end if
         file.name=newname & "-" & d.Item(newname) & ".jpg"
     end if
next
'=========================================
-- 
Crash

"The real question is not whether machines think but whether men do."
~ B. F. Skinner ~
0
Dave
6/6/2010 3:35:46 PM

"James Watkins" <someone@microsoft.com> wrote in message 
news:ORXo4OOBLHA.1888@TK2MSFTNGP05.phx.gbl...
>
> "Dave "Crash" Dummy" <invalid@invalid.invalid> wrote in message 
> news:cAqOn.91072$rE4.32891@newsfe15.iad...
>> 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 ~
>
> The OP's question was "Can someone tell if its possible to replace the 
> basename of a number of .jpg files in specified folder to match their date 
> stamp?". Your comprehensive reply reminds me of the saying "Give a man a 
> fish; you have fed him for today. Teach a man to fish; and you have fed 
> him for a lifetime".

Nice observation. The OP should now be able to eat "datestamped file" fish 
for the rest of his life. Not so sure that he will be able to eat "asking 
the intended question" fish ;-)

To the OP: if you are confused by my comment, what I mean is that you 
probably meant to ask "How can I write a script to replace...". In the old 
days a question such as yours would likely get numerous responses of these 
varieties:

"Yes, someone probably could tell you whether or not it is possible..."
"Yes, it is possible..."

/Al
 

0
Al
6/6/2010 10:48:39 PM
Crash, 
Many thanks, its amazing!;-) the script worked like a charm, the result 
looks different than what I get by using the FOR command in cmd, but its much 
easier to use and error-free. 
Great help!

"Dave "Crash" Dummy" wrote:

> Oleg wrote:
> > 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.
> 
> Pegasus' second suggestion, appending the date-time string to the
> original name, is the simplest. His first suggestion, adding a numerical
> suffix, can be implemented using a dictionary object. The reworked
> script below does that.
> 
> '=================rename.vbs================
> set fso=CreateObject("Scripting.FileSystemObject")
> set objFolder=fso.getFolder("e:\pics")
> 
> Set d=CreateObject("Scripting.Dictionary")
> 
> 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,":","-")
> 	if d.Exists(newname) then
> 		d.Item(newname)=d.Item(newname)+1
> 	else
> 		d.Add newname,1
> 	end if
>          file.name=newname & "-" & d.Item(newname) & ".jpg"
>      end if
> next
> '=========================================
> -- 
> Crash
> 
> "The real question is not whether machines think but whether men do."
> ~ B. F. Skinner ~
> .
> 
0
Utf
6/8/2010 6:36:24 AM
Dave, 
Can you explain couple of things in you script? Im trying to understand how 
it works.
1. You set d as Scripting Distionary - d must be there or any word or letter 
can be set as S.Dictionary?
2. In line if right(filename,4)=".jpg" then   - what does 4 stand for?
3. Also in line d.Add newname,1  im wondering what 1 means...

Thanks for your time and patience! :)

"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 ~
> .
> 
0
Utf
6/8/2010 7:03:38 AM
Pegasus, 
Adding a numerical value works better in my case, as my camera gives prety 
long names to the pictures, smth like Picturexxxxxxxx, if I add a date on top 
of that, the name would be too long, I'd like to avoid that

"Pegasus [MVP]" wrote:

> Moving the file before renaming it would mitigate the problem but not 
> eliminate it. To really eliminate it you need to expand the file name with a 
> numerical suffix that you keep increasing until it becomes unique. A better 
> alternative would be not to rename the file but to add the date stamp to the 
> existing file name. In this way you would not get any duplicate names at 
> all.
> 
> "Oleg" <Oleg@discussions.microsoft.com> wrote in message 
> news:DA63C844-D044-437C-92FD-3C395C7E02DC@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 ~
> >> .
> >> 
> .
> 
0
Utf
6/8/2010 7:03:39 AM
Sorry for the bad formulation of my question :) English is not my native 
lang., and still new to this forum, will try to be more specific in next 
posts ;) 
Still, I didnt get any OT replies :)

"Al Dunbar" wrote:

> 
> 
> "James Watkins" <someone@microsoft.com> wrote in message 
> news:ORXo4OOBLHA.1888@TK2MSFTNGP05.phx.gbl...
> >
> > "Dave "Crash" Dummy" <invalid@invalid.invalid> wrote in message 
> > news:cAqOn.91072$rE4.32891@newsfe15.iad...
> >> 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 ~
> >
> > The OP's question was "Can someone tell if its possible to replace the 
> > basename of a number of .jpg files in specified folder to match their date 
> > stamp?". Your comprehensive reply reminds me of the saying "Give a man a 
> > fish; you have fed him for today. Teach a man to fish; and you have fed 
> > him for a lifetime".
> 
> Nice observation. The OP should now be able to eat "datestamped file" fish 
> for the rest of his life. Not so sure that he will be able to eat "asking 
> the intended question" fish ;-)
> 
> To the OP: if you are confused by my comment, what I mean is that you 
> probably meant to ask "How can I write a script to replace...". In the old 
> days a question such as yours would likely get numerous responses of these 
> varieties:
> 
> "Yes, someone probably could tell you whether or not it is possible..."
> "Yes, it is possible..."
> 
> /Al
>  
> 
> .
> 
0
Utf
6/8/2010 7:03:40 AM
Oleg wrote:
> Dave, Can you explain couple of things in you script? Im trying to 
> understand how it works. 1. You set d as Scripting Distionary - d 
> must be there or any word or letter can be set as S.Dictionary?

Any letter or unrestricted word (a word not reserved by VBScript) can be
used.

> 2. In line if right(filename,4)=".jpg" then   - what does 4 stand 
> for?

4 is the number of characters from the end of the string.
Right("characters",4) would be "ters"

> 3. Also in line d.Add newname,1  im wondering what 1 means...

"1" is the initial item for the newname key. That's where the numeric
suffix for your new filename will come from. It will increase by one
whenever a duplicate date-time string occurs.

I strongly suggest you download the VBScript help file and look up
"dictionary" and other terms used in the script Sorry. It is only available
in English. Watch for line wrap!

http://download.microsoft.com/download/9/1/d/91dfd1b3-a274-4e17-a376-f605ff39c58c/script56.chm

Bookmark this site:
http://msdn.microsoft.com/en-us/library/t0aew7h6(v=VS.85).aspx

> Thanks for your time and patience! :)

-- 
Crash

Ignorance is curable. Stupidity is refusing treatment.
0
Dave
6/8/2010 10:33:17 AM
Dave, 
Thanks, that will occupy me for some time. Its much more fun to work with 
scripts that win GI ;-) and a lot to learn... 

"Dave "Crash" Dummy" wrote:

> Oleg wrote:
> > Dave, Can you explain couple of things in you script? Im trying to 
> > understand how it works. 1. You set d as Scripting Distionary - d 
> > must be there or any word or letter can be set as S.Dictionary?
> 
> Any letter or unrestricted word (a word not reserved by VBScript) can be
> used.
> 
> > 2. In line if right(filename,4)=".jpg" then   - what does 4 stand 
> > for?
> 
> 4 is the number of characters from the end of the string.
> Right("characters",4) would be "ters"
> 
> > 3. Also in line d.Add newname,1  im wondering what 1 means...
> 
> "1" is the initial item for the newname key. That's where the numeric
> suffix for your new filename will come from. It will increase by one
> whenever a duplicate date-time string occurs.
> 
> I strongly suggest you download the VBScript help file and look up
> "dictionary" and other terms used in the script Sorry. It is only available
> in English. Watch for line wrap!
> 
> http://download.microsoft.com/download/9/1/d/91dfd1b3-a274-4e17-a376-f605ff39c58c/script56.chm
> 
> Bookmark this site:
> http://msdn.microsoft.com/en-us/library/t0aew7h6(v=VS.85).aspx
> 
> > Thanks for your time and patience! :)
> 
> -- 
> Crash
> 
> Ignorance is curable. Stupidity is refusing treatment.
> .
> 
0
Utf
6/8/2010 12:40:06 PM

"Oleg" <Oleg@discussions.microsoft.com> wrote in message 
news:7E1844E7-9C35-44CB-A7AF-0084C603B62B@microsoft.com...
> Sorry for the bad formulation of my question :) English is not my native
> lang., and still new to this forum, will try to be more specific in next
> posts ;)
> Still, I didnt get any OT replies :)

No problem. My comments were not meant as criticism, but to try to 
demonstrate that your question could have been worded more effectively.

/Al

> "Al Dunbar" wrote:
>
>>
>>
>> "James Watkins" <someone@microsoft.com> wrote in message
>> news:ORXo4OOBLHA.1888@TK2MSFTNGP05.phx.gbl...
>> >
>> > "Dave "Crash" Dummy" <invalid@invalid.invalid> wrote in message
>> > news:cAqOn.91072$rE4.32891@newsfe15.iad...
>> >> 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 ~
>> >
>> > The OP's question was "Can someone tell if its possible to replace the
>> > basename of a number of .jpg files in specified folder to match their 
>> > date
>> > stamp?". Your comprehensive reply reminds me of the saying "Give a man 
>> > a
>> > fish; you have fed him for today. Teach a man to fish; and you have fed
>> > him for a lifetime".
>>
>> Nice observation. The OP should now be able to eat "datestamped file" 
>> fish
>> for the rest of his life. Not so sure that he will be able to eat "asking
>> the intended question" fish ;-)
>>
>> To the OP: if you are confused by my comment, what I mean is that you
>> probably meant to ask "How can I write a script to replace...". In the 
>> old
>> days a question such as yours would likely get numerous responses of 
>> these
>> varieties:
>>
>> "Yes, someone probably could tell you whether or not it is possible..."
>> "Yes, it is possible..."
>>
>> /Al
>>
>>
>> .
>> 
0
Al
6/10/2010 12:07:32 AM
"Oleg" <Oleg@discussions.microsoft.com> wrote in message 
news:DA63C844-D044-437C-92FD-3C395C7E02DC@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! 


0
Kenneth
7/27/2010 11:22:44 PM
Reply:

Similar Artilces:

Automatic transfer/download match up
From my paycheck, I have $250 withdrawn and placed into a separate bank account. When I download my transactions for this separate bank account, it downloads the $250 transaction and doesn't realize this is the same transaction as the transfer from my main bank account. My question: is there anyway I can force Money to always match this transaction? The way I do it now is to delete the transaction that I downloaded and keep the one that shows as an automatic transfer. Thanks for any ideas! Joey ...

Converting XLS file to QIF or to OFX
How do I safely and securely convert an excel file (xls) to a QIF or OFX file? "dreamchaser" wrote: > How do I safely and securely convert an excel file (xls) to a QIF or OFX file? In Excel, save the file to CSV and ustilise iCreateOFX Basic from: http://icreateofx.co.uk/Convert-CSV-to-OFX to convert the saved CSV file to OFX. ...

Payment For Invoice
In my business account, I have payments for invoices. When I download from my bank, they never match up. I try to match them manually, and it won't let me. I delete the downloaded transaction, and it shows back up on the next download. How can I work around this, and still show that my customer made a payment? C'mon... I know people from Microsoft are looking at this forum. Why haven't I received an answer yet?? This is a serious matter, and I'm 99.9% sure I'm not the only one who's been in this situation. JB2K "JB2K" <spam_catcher...@jb2k.c...

conversion lotus 123 files to excel -- problem
I am converting lotus123 files to excel2002. One problem is that in lotus, literals are ignored when found in a cell within a formula. Excel on the other hand is not doing this and therefore causing #value errors on all the formulas where this occurs. Is there a way to handle this in excel other than manually having to change all the formulas? ...

Date Range Formula Question
Hello, I'm having trouble with a formula and I'm hoping someone can help. :confused: Sample Data Includes the following: Pay Period Start Pay Period End Pay Period # 12/16/01 12/29/01 26 12/30/01 01/12/02 25 01/13/01 01/26/02 24 01/27/02 02/09/02 23 02/10/02 02/23/02 22 The pay periods continue until there are 26 pay periods for the entire year....

How do I get excel files to open automatically from directories?
When I try to open excel files from the directory or from desktop I only get a blank worksheet not the file. I have to then go through File Open to get the file I want. There must be a way to have them open automatically. On Mon, 2 Jan 2006 21:22:01 -0800, Damian <Damian@discussions.microsoft.com> wrote: >When I try to open excel files from the directory or from desktop I only get >a blank worksheet not the file. I have to then go through File Open to get >the file I want. > >There must be a way to have them open automatically. Go to Tools -> Options -> Gen...

Time Zone / Incorrect Dates Displayed to User
When a user in the Central Time zone closes an opportunity and someone in the Mountain Time zone views it, the Actual Close Date is 1 day before the date the person in the Central Time zone selected. For instance... If someone in the Central Time zone closes an opportunity and selects the Actual Close Date as 6/2/2007: -- Users in the Central Time zone see: 6/2/2007 -- But users in the Mountain Time zone see: 6/1/2007 This is a big issue when running monthly reports as it makes some opportunities show in the wrong month... and will put that revenue in the wrong month. It would make mo...

Odd problem with worksheets when opening file
Okay, here's the odd problem that's come up. When you double click on a excel file, excel opens up, but you can onl see the toolbars. The grid area looks like a snapshot of whatever you current background is before the file opened up. If you were showin your desktop, after the excel file opened, you'd still see your deskto in the datagrid area. If you start up a new excel file, then do the File>Open>file name, th file will open correctly. This problem happens across users here. Everyone is currently runnin office 2K. Any ideas on what causes the problem and any...

Outlook 2002 multiple file opening
In Outlook 2000, CTRL A would select all attached picture files, then Open would, in my case, open the files in Paintshop Pro. With the 2002 version I cannot find a way to do this. Any suggestions? ...

"File: send to mail recipient" not working
When users (on WinXP) select file, "send to mail recipient", no response from Outlook 2002. This occurs either when Outlook is open or closed. Problem happens when rt. clicking on .doc, .xls, .pdf's....all files. Any ideas?? Thanks!! ...

odd files created
Every time I open and edit an excel spreadsheet on a network share, small odd files get created. They are usually no larger than 25-40k and don't have any extensions to them. Looking at the properties page for any file, the file description says File. Anyone know what this is from or how to get rid of them? Permissions are setup correctly for me, Word files don't have this behavior. Excel 2000 SP3 Thanks, Hi Brian, A file the same size as the workbook would be created in the same directory as the workbook. The filename would be nonsensical (or appear to be random) character...

adding date/time picker to inputbox control
Hi all,is there a way to add a date/time picker control to inputbox?...

Excel Template Wizard, Very Large File Size
Background: Excel 2000. I created a spreadsheet and used the template wizard that links to an Access 2000 database. The template was later used to create one record and saved as a spreadsheet. The database also contains this one record. Spreadsheet and database work fine. Later I reduced the Access field size properties (none are larger than 150, most are less than 50). There are 35 fields. Unexpected result: The Excel spreadsheet (template) and the linked Access database are huge. The spreadsheet is 35MB and the associated Access 2000 database is 24MB. Each contains one record (a si...

number of results columns doesnt match table defintion
This is the error I get when among other things, I try to print a financial report. Actually the error popup says "A get/change operation on table 'GL_Options_ROPT' failed accessing SQL data", the more button reveals the number of columns error description. This database was restored by copying the sql folder from a previous installation into the new servers sql folder. Thanks. shawn modersohn wrote: > This is the error I get when among other things, I try to print a > financial report. Actually the error popup says "A get/change operation > on ta...

Money fails to match similar transactions, bug?
Money fails to automatically match, netiher does it want to allow me to manually match, similar looking transactions. I have a yearly bill from my service provider for 3 domains. I have 3 recurring transactions in bills and deposits that have exactly the same information, except the memo field is different, each for a domain. I downloaded 3 transactions, each supposed to match one of the 3 entries in bills and deposits. Money matches one transaction, but does not allow me to match the other two. It seems there is a logic bug that prevents money from matching more than one similar looki...

Date & Time file was last saved
Is there away to display in a cell the date & time the file was last saved? I know you can do this in word but is it possible in Excel 2002? Here is an UDF Function DocProps(prop As String) application.volatile On Error GoTo err_value DocProps = ActiveWorkbook.BuiltinDocumentProperties(prop) Exit Function err_value: DocProps = CVErr(xlErrValue) End Function Now you can use the following formula in one of your cells: =DocProps("Last save time") Obviously, the file has to have been saved. -- HTH Bob Phillips ... looking out across Poole Harbour to ...

Add working hours to date field
We offer computer support based on a certain response time in hours. I want to have a date field, on the case form, to automatically set x WORKING hours ahead, usually 8 hours. The actually hour value will be pulled from a contract. Does anyone know if this is possible or am I shooting way too high? ...

date macro
HI! Thanks in advance for helping. I would like to run a macro on a user form to take the date of report and see if the date is on or past the 26th and send the report to the its designated worksheet. looped. example: IF the report is anywhere created from 26th of the previous month to 25th of current month to go in to spreedsheet of that current month and continue on till project is finished. starting with the first day of contract to be awarded. the problem is i have to use thier form on excel. the thing is, the report will only have a "todays date" and the data to follow...

Caculating Columns Between Certain Dates
I have a spread sheet with for simplicity 4 columns Column 1 is a Date Column, Column 2 is a Company Name, Column 3 is a Payment amount X Column 4 is a Payment amount Y The amount due is the sum of X+Y between the relevant dates. The entries are in date order and the Company names random. The number of entries per company varies also. I want to be able to calculate the amount due for each company over a thee month period between certain varied dates. Questions 1. Is there a way to enter the dates to calculate between. 2. What is the best way to perform the calculations for each company?...

Post Exp Date in Master Rcd (row) from trans record
Hi, I'm using Access 2003 via Xp Office Pro. I'm working on a annual membership database. Each member has to renew each year if they want to stay a member. I want to keep a history of their membership. I have a membership table and will have a renewal table where I create a record / row each time a member renews. Key to both tables are automatic generated numbers. When I post the renewal transactions, I would like to change the expiration date that is on the master record. I realize that I would have the same data in both records, but for simplicity of the r...

Extracting the month that a date refers to in another cell
In cell A1 I have the date 3/15/2003 (no formatting). In cell B1 I have the formula =year(A1). The year shows correctly as 2003. In cell C1 I have the formula =text(weekday(A1),"ddd"). The text shows as "Sat" which is correct. In cell D1 I have the formula =month(A1) which correctly shows '3'. I attempted to use =text(month(A1),"mmm") in cell D1, but it shows as "Jan". Can someone tell me what I am doing wrong? TIA, Alan =TEXT(A1,"mmm") for 3-letter month name and =TEXT(A1,"ddd") for 3-letter day name. where A1 houses a...

OL2000
When opening an attachment in OL2000, the program creates a file in a temporary directory on my hard drive under C:\Documents and Settings\User\Local Settings\Temporary Internet Files\OLK6A2\. This directory is filling up and I would like to clear it. Unfortunately in XP SP2, this directly is not visible in when exploring files in my computer. I believe that I have all "show hidden files and folders" settings checked. Also, the file explorer shows (sometimes) that there is a sub directory under "temporary internet files," but it does not show up when I look further....

Corrupt Access 2003 File
I was working on this file earlier today, I even just opened it and it was fine and all of a sudden there is a write delay to the save the file, I closed it and I try opening it again and it is corrupted. I don't get it. The message I am getting is below. What does that mean. I just finished making a lost of update to the file. The last time I backed it up was Tuesday, and I have done a lot of work to it between then and now. I don't have the time to go back and redo all that work again. Any help will be appreciated. "Microsoft Office Access has detected corruption in this ...

text to date..!!
if i am having a date in a cell as 30/11/2005 but formatted in text, what's the procedure to change the same to date format as "30-Mar-2005"? thks & regds! via135 -- via135 ------------------------------------------------------------------------ via135's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=26725 View this thread: http://www.excelforum.com/showthread.php?threadid=495816 sorry! a small correction! if i am having a date in a cell as 30/11/2005 but formatted in text, what's the procedure to change the same to date format as &q...

Missing File Names
Version: 2004 Operating System: Mac OS X 10.5 (Leopard) Processor: Power PC When clicking on an Excel file I get the following message: ':Mac Excel Expander:Mac Excel Expander' could not be found. I also get this message when trying to launch a Word file. I have recently removed Office 2008 and reinstalled 2004. Thanks ...