Abhijat Singh | 3 Nov 17:25 2010
Picon

largest file in a directory

Hi Everybody,
I need some help and it can be pretty silly for experts like you. I need a dos snippet which will find the
largest file in a directory and echo file name, size and timestamp of that file.

Lets say the directory is C:\Batch

Thanks very much!

Kind Regards,
Abhijat.

------------------------------------

To Post a message, send it to:   batchworld@...

To Unsubscribe, send a blank message to:
batchworld-unsubscribe@...! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/batchworld/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/batchworld/join
    (Yahoo! ID required)

<*> To change settings via email:
    batchworld-digest@... 
(Continue reading)

foxidrive | 3 Nov 20:13 2010

Re: largest file in a directory

On 4/11/2010 03:25, Abhijat Singh wrote:
> Hi Everybody, I need some help and it can be pretty silly for experts
> like you. I need a dos snippet which will find the largest file in a
> directory and echo file name, size and timestamp of that file.
>
> Lets say the directory is C:\Batch

 <at> echo off
pushd "c:\batch"
for /f "delims=" %%a in ('dir /b /o:-s') do (
echo %%a %%~za %%~ta
goto :next
)
:next
popd
pause

------------------------------------

To Post a message, send it to:   batchworld@...

To Unsubscribe, send a blank message to:
batchworld-unsubscribe@...! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/batchworld/

<*> Your email settings:
    Individual Email | Traditional

(Continue reading)

Parag Doke | 4 Nov 09:14 2010
Picon

Re: largest file in a directory

Hello again Mic.
Sorry for jumping on to this thread started by Abhijat ... but maybe there
is something I could learn.

There is this goto :next line within the for loop. I tried out the snippet
you shared and noticed that it is similar to the break for/exit for
statement for other languages/scripts. The other way to run something from a
label is to use call :label. But possibly the latter will return control
flow to the for loop whereas goto simply never returns.

So just to summarize:
1) To break out of a for, use a goto :label statement in the loop.
The other way I knew of (from commandline.co.uk -  Eric Lawrence's site) was
something similar to this:
for /f %a in ('some command') do if not defined var set var=%a
process var further
But it iterates over the others in the output of the command and therefore
your method seems better.

2) Using goto within a for loop will not return control flow back into it
(even if it hits the EOF) which is unlike call.

Please correct me if I am wrong.
Thanks in advance !
Parag Doke

On Thu, Nov 4, 2010 at 12:43 AM, foxidrive <foxidrive@...> wrote:

>
>
(Continue reading)

foxidrive | 4 Nov 13:31 2010

Re: largest file in a directory

On 4/11/2010 19:14, Parag Doke wrote:
> Hello again Mic.
> Sorry for jumping on to this thread started by Abhijat ... but maybe there
> is something I could learn.

It's always good to get some dialogue going. :)

> There is this goto :next line within the for loop. I tried out the snippet
> you shared and noticed that it is similar to the break for/exit for
> statement for other languages/scripts. The other way to run something from a
> label is to use call :label. But possibly the latter will return control
> flow to the for loop whereas goto simply never returns.
>
> So just to summarize:
> 1) To break out of a for, use a goto :label statement in the loop.

> The other way I knew of (from commandline.co.uk -  Eric Lawrence's site) was
> something similar to this:
> for /f %a in ('some command') do if not defined var set var=%a
> process var further

That's a useful tip.  The "if not defined" test would be quite fast for 
a long list of filenames and better than the alternate solution that I 
outline below.

> But it iterates over the others in the output of the command and therefore
> your method seems better.

Another method of getting either smallest or greatest etc is to use the 
sort switch appropriately (adding or removing the minus) so that the 
(Continue reading)

Aristos Vasiliou | 18 Nov 15:13 2010
Picon

enter weird named folder and run exe

I have this weird looking folder structure. http://img690.imageshack.us/img690/1196/43380325.jpg

In each of these folders there’s a folder named "update"
In each "update" folder there’s an executable named "update.exe"

How can I make a batch file that will enter each weird named folder, enter the "update" folder and run
"update.exe /quiet /passive /norestart" ?

Thanks

[Non-text portions of this message have been removed]

------------------------------------

To Post a message, send it to:   batchworld@...

To Unsubscribe, send a blank message to: batchworld-unsubscribe@...
Parag Doke | 18 Nov 15:20 2010
Picon

Re: enter weird named folder and run exe

My attempt:
Assuming the parent folder is ABC, this batch file is worth a try:
pushd ABC
for /f %%a in ('dir /b /ad') do (
    cd %%a\update
    echo update.exe /quiet /passive /norestart
    cd ..
)
popd

If it is found ok, remove the echo.

Thanks,
Parag

On Thu, Nov 18, 2010 at 7:43 PM, Aristos Vasiliou <aristos@...>wrote:

> I have this weird looking folder structure.
> http://img690.imageshack.us/img690/1196/43380325.jpg
>
>
>
> In each of these folders there’s a folder named "update"
> In each "update" folder there’s an executable named "update.exe"
>
>
>
> How can I make a batch file that will enter each weird named folder, enter
> the "update" folder and run "update.exe /quiet /passive /norestart" ?
>
(Continue reading)

Parag Doke | 18 Nov 15:22 2010
Picon

Re: enter weird named folder and run exe

Sorry for a repost, but update.exe might return control to the batch file
immediately.
Modifying the line to
    echo start /wait "" update.exe /quiet /passive /norestart

On Thu, Nov 18, 2010 at 7:50 PM, Parag Doke <paragpdoke@...> wrote:

> My attempt:
> Assuming the parent folder is ABC, this batch file is worth a try:
> pushd ABC
> for /f %%a in ('dir /b /ad') do (
>     cd %%a\update
>     echo start /wait "" update.exe /quiet /passive /norestart
>     cd ..
> )
> popd
>
> If it is found ok, remove the echo.
>
> Thanks,
> Parag
>
>
> On Thu, Nov 18, 2010 at 7:43 PM, Aristos Vasiliou <aristos@...>wrote:
>
>> I have this weird looking folder structure.
>> http://img690.imageshack.us/img690/1196/43380325.jpg
>>
>>
>>
(Continue reading)

Aristos Vasiliou | 18 Nov 15:31 2010
Picon

RE: enter weird named folder and run exe

I think there's something wrong with the paths

http://img29.imageshack.us/img29/6690/15770564.jpg

________________________________________
From: batchworld@...
[batchworld@...] on behalf of Parag Doke [paragpdoke@...]
Sent: Thursday, November 18, 2010 4:22 PM
To: batchworld@...
Subject: Re: [BATCH WORLD] enter weird named folder and run exe

Sorry for a repost, but update.exe might return control to the batch file
immediately.
Modifying the line to
    echo start /wait "" update.exe /quiet /passive /norestart

On Thu, Nov 18, 2010 at 7:50 PM, Parag Doke <paragpdoke@...> wrote:

> My attempt:
> Assuming the parent folder is ABC, this batch file is worth a try:
> pushd ABC
> for /f %%a in ('dir /b /ad') do (
>     cd %%a\update
>     echo start /wait "" update.exe /quiet /passive /norestart
>     cd ..
> )
> popd
>
> If it is found ok, remove the echo.
>
(Continue reading)

foxidrive | 19 Nov 01:09 2010

Re: enter weird named folder and run exe


Parag, I think there was some confusion about which folder it was 
entering...  (cd %%a\update)

Try this modification of Parag's code, Aristos

 <at> echo off
pushd "ABC"
for /f "delims=" %%a in ('dir /b /ad') do (
       pushd "%%a"
       echo folder "%%a"
       start "" /w update.exe /quiet /passive /norestart
       popd
  )
popd

On 19/11/2010 01:20, Parag Doke wrote:
> My attempt:
> Assuming the parent folder is ABC, this batch file is worth a try:
> pushd ABC
> for /f %%a in ('dir /b /ad') do (
>      cd %%a\update
>      echo update.exe /quiet /passive /norestart
>      cd ..
> )
> popd
>
> If it is found ok, remove the echo.
>
> Thanks,
(Continue reading)

Aristos Vasiliou | 19 Nov 07:45 2010
Picon

RE: enter weird named folder and run exe

I tried this:

 <at> echo off
pushd "Updates"
for /f "delims=" %%a in ('dir /b /ad') do (
       pushd "%%a"
       echo folder "%%a"
       start "" /w update.exe /quiet /passive /norestart
       popd
  )
popd

and this:

 <at> echo off
pushd "Updates"
for /f "delims=" %%a in ('dir /b /ad') do (
       pushd "%%a"
       echo folder "%%a"
       cd %%a\update
       start "" /w update.exe /quiet /passive /norestart
       popd
  )
popd

But no luck. These are the results

1. http://img841.imageshack.us/img841/1470/31365629.jpg
2. http://img713.imageshack.us/img713/8305/90630451.jpg

(Continue reading)


Gmane