From: "Dave "Crash" Dummy" on
cjake2299 wrote:
> Greetings all-
>
> I have a directory that contains image files (lots of them) that all
> end with "_STD.jpg". I need to remove the "_STD" portion of all the
> file names, as well as return a count of all files processed. Any
> help would be much appreciated.

Maybe I'm missing something, but wouldn't this work?

Set fso = CreateObject("Scripting.FileSystemObject")
set fldr=fso.getFolder("d:\directory")
filecount=0
for each file in fldr.files
if instr(ucase(file.name),"_STD.JPG") then
dname=replace(file.path,"_STD","")
file.move dname
filecount=filecount+1
end if
next

--
Crash

Committed to the search for intraterrestrial intelligence.
From: Paul Randall on

"Dave "Crash" Dummy" <invalid(a)invalid.invalid> wrote in message
news:umtye04fKHA.2160(a)TK2MSFTNGP02.phx.gbl...
> cjake2299 wrote:
>> Greetings all-
>>
>> I have a directory that contains image files (lots of them) that all
>> end with "_STD.jpg". I need to remove the "_STD" portion of all the
>> file names, as well as return a count of all files processed. Any
>> help would be much appreciated.
>
> Maybe I'm missing something, but wouldn't this work?
>
> Set fso = CreateObject("Scripting.FileSystemObject")
> set fldr=fso.getFolder("d:\directory")
> filecount=0
> for each file in fldr.files
> if instr(ucase(file.name),"_STD.JPG") then
> dname=replace(file.path,"_STD","")
> file.move dname
> filecount=filecount+1
> end if
> next

The name property of a FSO file object has both read and write capabilities,
doesn't it?
Maybe omething like the following for changing the name?
file.name = replace(file.name, "_STD","")


From: Stefan Kanthak on
"Paul Randall" <paulr901(a)cableone.net> wrote:
>
> "Dave "Crash" Dummy" <invalid(a)invalid.invalid> wrote in message
> news:umtye04fKHA.2160(a)TK2MSFTNGP02.phx.gbl...
>> cjake2299 wrote:
>>> Greetings all-
>>>
>>> I have a directory that contains image files (lots of them) that all
>>> end with "_STD.jpg". I need to remove the "_STD" portion of all the
>>> file names, as well as return a count of all files processed. Any
>>> help would be much appreciated.
>>
>> Maybe I'm missing something, but wouldn't this work?

[ "bloated" VBScript ]

Why not a simple *.CMD?

ChDir /D "<directory>"
For %! In (*_STD.jpg) Do Rename "%!" "%!:_STD="

The count is left as exercise for the reader.

Stefan

From: "Dave "Crash" Dummy" on
Paul Randall wrote:
> "Dave "Crash" Dummy" <invalid(a)invalid.invalid> wrote in message
> news:umtye04fKHA.2160(a)TK2MSFTNGP02.phx.gbl...
>> cjake2299 wrote:
>>> Greetings all-
>>>
>>> I have a directory that contains image files (lots of them) that
>>> all end with "_STD.jpg". I need to remove the "_STD" portion of
>>> all the file names, as well as return a count of all files
>>> processed. Any help would be much appreciated.
>> Maybe I'm missing something, but wouldn't this work?
>>
>> Set fso = CreateObject("Scripting.FileSystemObject") set
>> fldr=fso.getFolder("d:\directory") filecount=0 for each file in
>> fldr.files if instr(ucase(file.name),"_STD.JPG") then
>> dname=replace(file.path,"_STD","") file.move dname
>> filecount=filecount+1 end if next
>
> The name property of a FSO file object has both read and write
> capabilities, doesn't it? Maybe omething like the following for
> changing the name? file.name = replace(file.name, "_STD","")

Yes, it would. I adopted my script from another application, and there
was some reason (which I forget) that I couldn't do it directly. The two
lines

dname=replace(file.path,"_STD","")
file.move dname

could be replaced with

file.name = replace(file.name, "_STD","")

--
Crash

"When you get to a fork in the road, take it."
~ Yogi Berra ~
From: "Dave "Crash" Dummy" on
> I adopted my script from another application, and there
> was some reason (which I forget) that I couldn't do it directly.

Ah! Now I remember! I didn't want to change the name, exactly, I wanted
to change the case. I can't do that directly because VBS doesn't
distinguish case in file names. For example, if I try to change "_STD"
to "_std,"

This won't work:
file.name = replace(file.name, "_STD","_std")

This will:
dname=replace(file.path,"_STD","_std")
file.move dname

--
Crash

Life is short. Eat dessert first.