Is it possible to use vbscript to rename a folder full of jpgs, giving each
one a new name with its size in kilobytes?

So "sample.jpg" would become "29.jpg" indicating that the file size of
29.jpg is 20 kb.

Re: rename a folder full of jpgs with the size of the file by Michael

Michael
Mon Jul 10 09:19:56 CDT 2006

On Mon, 10 Jul 2006 10:08:52 GMT, "Max Bialystock" wrote in
microsoft.public.scripting.vbscript:

>Is it possible to use vbscript to rename a folder full of jpgs, giving each
>one a new name with its size in kilobytes?
>
>So "sample.jpg" would become "29.jpg" indicating that the file size of
>29.jpg is 20 kb.

And how do you want to deal with files of the same size in KB?

Trivial with the right tool. This one-liner works, using 4NT:
For %fn IN (*.jpg) REN "%fn" %@FILESIZE["%fn",K].jpg

Upper case K will show size in 2**10, lower case k in 10**3. 4NT is a
commercial product. @FILESIZE is documented at
<http://jpsoft.com/help/f_filesize.htm>.

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"

Re: rename a folder full of jpgs with the size of the file by Max

Max
Mon Jul 10 15:33:32 CDT 2006

Sorry there's a typo there.

So "sample.jpg" would become "29.jpg" indicating that the file size of
29.jpg is 29 kb.

Let's assume that there is a small number of jpeg files in the directory and
that they are of greatly diverse sizes.

So, for example, if the directory contains 3 files they might be: 30 kb, 120
kb, 560 kb.

I'm only looking for solutions that use VBS.

regards,
Max


"Max Bialystock" <bialystock@leggs.com> wrote in message
news:UGpsg.2420$tE5.474@news-server.bigpond.net.au...
> Is it possible to use vbscript to rename a folder full of jpgs, giving
> each one a new name with its size in kilobytes?
>
> So "sample.jpg" would become "29.jpg" indicating that the file size of
> 29.jpg is 20 kb.
>
>



Re: rename a folder full of jpgs with the size of the file by Jennifer

Jennifer
Mon Jul 10 16:45:10 CDT 2006

Dim fso
Dim fol
Dim Fil
Dim sFolderName

sFolderName = "whatever"

Set fso = CreateObject("scripting.filesystemobject")
Set fol = fso.GetFolder(sFolderName)

For Each Fil In fol.Files
Fil.Name = Fil.Size & ".jpg"
Next


Max Bialystock wrote:
> Sorry there's a typo there.
>
> So "sample.jpg" would become "29.jpg" indicating that the file size of
> 29.jpg is 29 kb.
>
> Let's assume that there is a small number of jpeg files in the directory and
> that they are of greatly diverse sizes.
>
> So, for example, if the directory contains 3 files they might be: 30 kb, 120
> kb, 560 kb.
>
> I'm only looking for solutions that use VBS.
>
> regards,
> Max
>
>
> "Max Bialystock" <bialystock@leggs.com> wrote in message
> news:UGpsg.2420$tE5.474@news-server.bigpond.net.au...
> > Is it possible to use vbscript to rename a folder full of jpgs, giving
> > each one a new name with its size in kilobytes?
> >
> > So "sample.jpg" would become "29.jpg" indicating that the file size of
> > 29.jpg is 20 kb.
> >
> >


Re: rename a folder full of jpgs with the size of the file by Max

Max
Wed Jul 12 04:08:55 CDT 2006

Thanks Jennifer,
That's a very neat solution.
Max


"Jennifer" <J.Evans.1970@gmail.com> wrote in message
news:1152567909.954497.54980@b28g2000cwb.googlegroups.com...
> Dim fso
> Dim fol
> Dim Fil
> Dim sFolderName
>
> sFolderName = "whatever"
>
> Set fso = CreateObject("scripting.filesystemobject")
> Set fol = fso.GetFolder(sFolderName)
>
> For Each Fil In fol.Files
> Fil.Name = Fil.Size & ".jpg"
> Next
>
>
> Max Bialystock wrote:
>> Sorry there's a typo there.
>>
>> So "sample.jpg" would become "29.jpg" indicating that the file size of
>> 29.jpg is 29 kb.
>>
>> Let's assume that there is a small number of jpeg files in the directory
>> and
>> that they are of greatly diverse sizes.
>>
>> So, for example, if the directory contains 3 files they might be: 30 kb,
>> 120
>> kb, 560 kb.
>>
>> I'm only looking for solutions that use VBS.
>>
>> regards,
>> Max
>>
>>
>> "Max Bialystock" <bialystock@leggs.com> wrote in message
>> news:UGpsg.2420$tE5.474@news-server.bigpond.net.au...
>> > Is it possible to use vbscript to rename a folder full of jpgs, giving
>> > each one a new name with its size in kilobytes?
>> >
>> > So "sample.jpg" would become "29.jpg" indicating that the file size of
>> > 29.jpg is 20 kb.
>> >
>> >
>