Technology Questions

Go Back   Technology Questions > Software Questions > Operating System Questions > Windows XP

Windows XP Discuss the Microsoft Windows XP Operating System

Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old 10-17-2008, 01:27 AM
Brandon
Newsgroup Contributor
 
Posts: n/a
Need Batch file to rename file based on file size

I need to create a "simple" batch file that will not only rename a specified
file to the date it was renamed (example: batch.log to batch-080508.log) but
also based on the file size limit (example: if file size is less than 50MB,
please rename batch.log to batch-080508.log)

Thanks,
B.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

 
Old 10-17-2008, 01:27 AM
  #2 (permalink)  
Old 10-17-2008, 01:27 AM
Pegasus \(MVP\)
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size


"Brandon" <Brandon@discussions.microsoft.com> wrote in message
news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
>I need to create a "simple" batch file that will not only rename a
>specified
> file to the date it was renamed (example: batch.log to batch-080508.log)
> but
> also based on the file size limit (example: if file size is less than
> 50MB,
> please rename batch.log to batch-080508.log)
>
> Thanks,
> B.


Assuming that "batch-080508.log" means "batch-mm-dd-yy.log,
where is the coding for the size? What if the file is > 50 MBytes?
Less than 10 MBytes? What if a file of the same name already
exists? You need to be nail down these issues before you can
start writing a batch file.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3 (permalink)  
Old 10-17-2008, 01:27 AM
Brandon
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size

There wouldn't be a file of the same name if it has the format:
"batch-mm-dd-yy.log". I don't know what the coding would be for the size
which is why I posted the question. Basically, I would need the batch file
to rename the log file (ex: batch.log) to "batch-080508.log" (or batch +
<date of renaming>.log) once the file reaches 50MB in size. If you can tell
me the syntax for the file size and the date, I can write the batch unless
there's a better way of writing the batch file.

thanks,
b.

"Pegasus (MVP)" wrote:

>
> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
> >I need to create a "simple" batch file that will not only rename a
> >specified
> > file to the date it was renamed (example: batch.log to batch-080508.log)
> > but
> > also based on the file size limit (example: if file size is less than
> > 50MB,
> > please rename batch.log to batch-080508.log)
> >
> > Thanks,
> > B.

>
> Assuming that "batch-080508.log" means "batch-mm-dd-yy.log,
> where is the coding for the size? What if the file is > 50 MBytes?
> Less than 10 MBytes? What if a file of the same name already
> exists? You need to be nail down these issues before you can
> start writing a batch file.
>
>
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #4 (permalink)  
Old 10-17-2008, 01:27 AM
Pegasus \(MVP\)
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size

This batch file will rename the specified file but only if its
size exceeds 50 kBytes:

01. @echo off
02. if "%*"=="" goto Error
03. if not exist "%*" goto Error
04.
05. set limit=50000
06. for /F %%a in ('echo %*') do if %%~za LSS %limit% goto error
07. for /F "tokens=2" %%a in ('echo %date%') do set MyDate=%%a
08. echo ren "%*" "batch-%MyDate:/=%.*
09. goto :eof
10.
11. :Error
12. echo.
13. echo No parameter given, or file does not exist,
14. echo or file size is less than 50 kBytes.

Invoke the batch file with the name of the file to-be-renamed
as a parameter. Do NOT surround the file name with double
quotes.

Remove the word "echo" in Line #08 to activate the batch file.


"Brandon" <Brandon@discussions.microsoft.com> wrote in message
news:87F0D5B0-763F-456B-999C-975D2850B1FC@microsoft.com...
> There wouldn't be a file of the same name if it has the format:
> "batch-mm-dd-yy.log". I don't know what the coding would be for the size
> which is why I posted the question. Basically, I would need the batch
> file
> to rename the log file (ex: batch.log) to "batch-080508.log" (or batch +
> <date of renaming>.log) once the file reaches 50MB in size. If you can
> tell
> me the syntax for the file size and the date, I can write the batch unless
> there's a better way of writing the batch file.
>
> thanks,
> b.
>
> "Pegasus (MVP)" wrote:
>
>>
>> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
>> >I need to create a "simple" batch file that will not only rename a
>> >specified
>> > file to the date it was renamed (example: batch.log to
>> > batch-080508.log)
>> > but
>> > also based on the file size limit (example: if file size is less than
>> > 50MB,
>> > please rename batch.log to batch-080508.log)
>> >
>> > Thanks,
>> > B.

>>
>> Assuming that "batch-080508.log" means "batch-mm-dd-yy.log,
>> where is the coding for the size? What if the file is > 50 MBytes?
>> Less than 10 MBytes? What if a file of the same name already
>> exists? You need to be nail down these issues before you can
>> start writing a batch file.
>>
>>
>>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #5 (permalink)  
Old 10-17-2008, 01:30 AM
Brandon
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size

Do you have the proper syntax since I must've executed it wrong.

thanks,
b.

"Pegasus (MVP)" wrote:

> This batch file will rename the specified file but only if its
> size exceeds 50 kBytes:
>
> 01. @echo off
> 02. if "%*"=="" goto Error
> 03. if not exist "%*" goto Error
> 04.
> 05. set limit=50000
> 06. for /F %%a in ('echo %*') do if %%~za LSS %limit% goto error
> 07. for /F "tokens=2" %%a in ('echo %date%') do set MyDate=%%a
> 08. echo ren "%*" "batch-%MyDate:/=%.*
> 09. goto :eof
> 10.
> 11. :Error
> 12. echo.
> 13. echo No parameter given, or file does not exist,
> 14. echo or file size is less than 50 kBytes.
>
> Invoke the batch file with the name of the file to-be-renamed
> as a parameter. Do NOT surround the file name with double
> quotes.
>
> Remove the word "echo" in Line #08 to activate the batch file.
>
>
> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> news:87F0D5B0-763F-456B-999C-975D2850B1FC@microsoft.com...
> > There wouldn't be a file of the same name if it has the format:
> > "batch-mm-dd-yy.log". I don't know what the coding would be for the size
> > which is why I posted the question. Basically, I would need the batch
> > file
> > to rename the log file (ex: batch.log) to "batch-080508.log" (or batch +
> > <date of renaming>.log) once the file reaches 50MB in size. If you can
> > tell
> > me the syntax for the file size and the date, I can write the batch unless
> > there's a better way of writing the batch file.
> >
> > thanks,
> > b.
> >
> > "Pegasus (MVP)" wrote:
> >
> >>
> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
> >> >I need to create a "simple" batch file that will not only rename a
> >> >specified
> >> > file to the date it was renamed (example: batch.log to
> >> > batch-080508.log)
> >> > but
> >> > also based on the file size limit (example: if file size is less than
> >> > 50MB,
> >> > please rename batch.log to batch-080508.log)
> >> >
> >> > Thanks,
> >> > B.
> >>
> >> Assuming that "batch-080508.log" means "batch-mm-dd-yy.log,
> >> where is the coding for the size? What if the file is > 50 MBytes?
> >> Less than 10 MBytes? What if a file of the same name already
> >> exists? You need to be nail down these issues before you can
> >> start writing a batch file.
> >>
> >>
> >>

>
>
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #6 (permalink)  
Old 10-17-2008, 01:30 AM
Pegasus \(MVP\)
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size

c:\Windows\MyBatchFile.bat d:\My Files\SomeEvent.log

When you have a problem, don't just write "I must have
executed it wrong". Report how you ran it and what message(s)
you saw. Remember - I can't see your screen!


"Brandon" <Brandon@discussions.microsoft.com> wrote in message
news:3279AC87-247B-4198-960B-E420AD8A3DA8@microsoft.com...
> Do you have the proper syntax since I must've executed it wrong.
>
> thanks,
> b.
>
> "Pegasus (MVP)" wrote:
>
>> This batch file will rename the specified file but only if its
>> size exceeds 50 kBytes:
>>
>> 01. @echo off
>> 02. if "%*"=="" goto Error
>> 03. if not exist "%*" goto Error
>> 04.
>> 05. set limit=50000
>> 06. for /F %%a in ('echo %*') do if %%~za LSS %limit% goto error
>> 07. for /F "tokens=2" %%a in ('echo %date%') do set MyDate=%%a
>> 08. echo ren "%*" "batch-%MyDate:/=%.*
>> 09. goto :eof
>> 10.
>> 11. :Error
>> 12. echo.
>> 13. echo No parameter given, or file does not exist,
>> 14. echo or file size is less than 50 kBytes.
>>
>> Invoke the batch file with the name of the file to-be-renamed
>> as a parameter. Do NOT surround the file name with double
>> quotes.
>>
>> Remove the word "echo" in Line #08 to activate the batch file.
>>
>>
>> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> news:87F0D5B0-763F-456B-999C-975D2850B1FC@microsoft.com...
>> > There wouldn't be a file of the same name if it has the format:
>> > "batch-mm-dd-yy.log". I don't know what the coding would be for the
>> > size
>> > which is why I posted the question. Basically, I would need the batch
>> > file
>> > to rename the log file (ex: batch.log) to "batch-080508.log" (or batch
>> > +
>> > <date of renaming>.log) once the file reaches 50MB in size. If you can
>> > tell
>> > me the syntax for the file size and the date, I can write the batch
>> > unless
>> > there's a better way of writing the batch file.
>> >
>> > thanks,
>> > b.
>> >
>> > "Pegasus (MVP)" wrote:
>> >
>> >>
>> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> >> news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
>> >> >I need to create a "simple" batch file that will not only rename a
>> >> >specified
>> >> > file to the date it was renamed (example: batch.log to
>> >> > batch-080508.log)
>> >> > but
>> >> > also based on the file size limit (example: if file size is less
>> >> > than
>> >> > 50MB,
>> >> > please rename batch.log to batch-080508.log)
>> >> >
>> >> > Thanks,
>> >> > B.
>> >>
>> >> Assuming that "batch-080508.log" means "batch-mm-dd-yy.log,
>> >> where is the coding for the size? What if the file is > 50 MBytes?
>> >> Less than 10 MBytes? What if a file of the same name already
>> >> exists? You need to be nail down these issues before you can
>> >> start writing a batch file.
>> >>
>> >>
>> >>

>>
>>
>>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #7 (permalink)  
Old 10-17-2008, 01:42 AM
Brandon
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size

You can't see my screen?? Just kidding! You're right, I'll try to
duplicate the process in detail for you and what I ran into.

I did get it to work using the syntax you provided. Thanks! Now, I need the
batch file (if possible) to stop a service, run the batch, then start the
service. Is this possible??

thanks again,
b.

"Pegasus (MVP)" wrote:

> c:\Windows\MyBatchFile.bat d:\My Files\SomeEvent.log
>
> When you have a problem, don't just write "I must have
> executed it wrong". Report how you ran it and what message(s)
> you saw. Remember - I can't see your screen!
>
>
> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> news:3279AC87-247B-4198-960B-E420AD8A3DA8@microsoft.com...
> > Do you have the proper syntax since I must've executed it wrong.
> >
> > thanks,
> > b.
> >
> > "Pegasus (MVP)" wrote:
> >
> >> This batch file will rename the specified file but only if its
> >> size exceeds 50 kBytes:
> >>
> >> 01. @echo off
> >> 02. if "%*"=="" goto Error
> >> 03. if not exist "%*" goto Error
> >> 04.
> >> 05. set limit=50000
> >> 06. for /F %%a in ('echo %*') do if %%~za LSS %limit% goto error
> >> 07. for /F "tokens=2" %%a in ('echo %date%') do set MyDate=%%a
> >> 08. echo ren "%*" "batch-%MyDate:/=%.*
> >> 09. goto :eof
> >> 10.
> >> 11. :Error
> >> 12. echo.
> >> 13. echo No parameter given, or file does not exist,
> >> 14. echo or file size is less than 50 kBytes.
> >>
> >> Invoke the batch file with the name of the file to-be-renamed
> >> as a parameter. Do NOT surround the file name with double
> >> quotes.
> >>
> >> Remove the word "echo" in Line #08 to activate the batch file.
> >>
> >>
> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> news:87F0D5B0-763F-456B-999C-975D2850B1FC@microsoft.com...
> >> > There wouldn't be a file of the same name if it has the format:
> >> > "batch-mm-dd-yy.log". I don't know what the coding would be for the
> >> > size
> >> > which is why I posted the question. Basically, I would need the batch
> >> > file
> >> > to rename the log file (ex: batch.log) to "batch-080508.log" (or batch
> >> > +
> >> > <date of renaming>.log) once the file reaches 50MB in size. If you can
> >> > tell
> >> > me the syntax for the file size and the date, I can write the batch
> >> > unless
> >> > there's a better way of writing the batch file.
> >> >
> >> > thanks,
> >> > b.
> >> >
> >> > "Pegasus (MVP)" wrote:
> >> >
> >> >>
> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> >> news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
> >> >> >I need to create a "simple" batch file that will not only rename a
> >> >> >specified
> >> >> > file to the date it was renamed (example: batch.log to
> >> >> > batch-080508.log)
> >> >> > but
> >> >> > also based on the file size limit (example: if file size is less
> >> >> > than
> >> >> > 50MB,
> >> >> > please rename batch.log to batch-080508.log)
> >> >> >
> >> >> > Thanks,
> >> >> > B.
> >> >>
> >> >> Assuming that "batch-080508.log" means "batch-mm-dd-yy.log,
> >> >> where is the coding for the size? What if the file is > 50 MBytes?
> >> >> Less than 10 MBytes? What if a file of the same name already
> >> >> exists? You need to be nail down these issues before you can
> >> >> start writing a batch file.
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #8 (permalink)  
Old 10-17-2008, 01:42 AM
Pegasus \(MVP\)
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size

Yes, it's possible.
net stop "Name of Service"
net start "Name of Service"

"Brandon" <Brandon@discussions.microsoft.com> wrote in message
news:05F62B46-435B-4536-A05B-0AFD3AEE0FA8@microsoft.com...
> You can't see my screen?? Just kidding! You're right, I'll try to
> duplicate the process in detail for you and what I ran into.
>
> I did get it to work using the syntax you provided. Thanks! Now, I need
> the
> batch file (if possible) to stop a service, run the batch, then start the
> service. Is this possible??
>
> thanks again,
> b.
>
> "Pegasus (MVP)" wrote:
>
>> c:\Windows\MyBatchFile.bat d:\My Files\SomeEvent.log
>>
>> When you have a problem, don't just write "I must have
>> executed it wrong". Report how you ran it and what message(s)
>> you saw. Remember - I can't see your screen!
>>
>>
>> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> news:3279AC87-247B-4198-960B-E420AD8A3DA8@microsoft.com...
>> > Do you have the proper syntax since I must've executed it wrong.
>> >
>> > thanks,
>> > b.
>> >
>> > "Pegasus (MVP)" wrote:
>> >
>> >> This batch file will rename the specified file but only if its
>> >> size exceeds 50 kBytes:
>> >>
>> >> 01. @echo off
>> >> 02. if "%*"=="" goto Error
>> >> 03. if not exist "%*" goto Error
>> >> 04.
>> >> 05. set limit=50000
>> >> 06. for /F %%a in ('echo %*') do if %%~za LSS %limit% goto error
>> >> 07. for /F "tokens=2" %%a in ('echo %date%') do set MyDate=%%a
>> >> 08. echo ren "%*" "batch-%MyDate:/=%.*
>> >> 09. goto :eof
>> >> 10.
>> >> 11. :Error
>> >> 12. echo.
>> >> 13. echo No parameter given, or file does not exist,
>> >> 14. echo or file size is less than 50 kBytes.
>> >>
>> >> Invoke the batch file with the name of the file to-be-renamed
>> >> as a parameter. Do NOT surround the file name with double
>> >> quotes.
>> >>
>> >> Remove the word "echo" in Line #08 to activate the batch file.
>> >>
>> >>
>> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> >> news:87F0D5B0-763F-456B-999C-975D2850B1FC@microsoft.com...
>> >> > There wouldn't be a file of the same name if it has the format:
>> >> > "batch-mm-dd-yy.log". I don't know what the coding would be for the
>> >> > size
>> >> > which is why I posted the question. Basically, I would need the
>> >> > batch
>> >> > file
>> >> > to rename the log file (ex: batch.log) to "batch-080508.log" (or
>> >> > batch
>> >> > +
>> >> > <date of renaming>.log) once the file reaches 50MB in size. If you
>> >> > can
>> >> > tell
>> >> > me the syntax for the file size and the date, I can write the batch
>> >> > unless
>> >> > there's a better way of writing the batch file.
>> >> >
>> >> > thanks,
>> >> > b.
>> >> >
>> >> > "Pegasus (MVP)" wrote:
>> >> >
>> >> >>
>> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> >> >> news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
>> >> >> >I need to create a "simple" batch file that will not only rename a
>> >> >> >specified
>> >> >> > file to the date it was renamed (example: batch.log to
>> >> >> > batch-080508.log)
>> >> >> > but
>> >> >> > also based on the file size limit (example: if file size is less
>> >> >> > than
>> >> >> > 50MB,
>> >> >> > please rename batch.log to batch-080508.log)
>> >> >> >
>> >> >> > Thanks,
>> >> >> > B.
>> >> >>
>> >> >> Assuming that "batch-080508.log" means "batch-mm-dd-yy.log,
>> >> >> where is the coding for the size? What if the file is > 50 MBytes?
>> >> >> Less than 10 MBytes? What if a file of the same name already
>> >> >> exists? You need to be nail down these issues before you can
>> >> >> start writing a batch file.
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>

>>
>>
>>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #9 (permalink)  
Old 10-17-2008, 01:43 AM
Brandon
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size

Is it as easy as putting the stop command within the batch file, and the
start command at the end??


"Pegasus (MVP)" wrote:

> Yes, it's possible.
> net stop "Name of Service"
> net start "Name of Service"
>
> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> news:05F62B46-435B-4536-A05B-0AFD3AEE0FA8@microsoft.com...
> > You can't see my screen?? Just kidding! You're right, I'll try to
> > duplicate the process in detail for you and what I ran into.
> >
> > I did get it to work using the syntax you provided. Thanks! Now, I need
> > the
> > batch file (if possible) to stop a service, run the batch, then start the
> > service. Is this possible??
> >
> > thanks again,
> > b.
> >
> > "Pegasus (MVP)" wrote:
> >
> >> c:\Windows\MyBatchFile.bat d:\My Files\SomeEvent.log
> >>
> >> When you have a problem, don't just write "I must have
> >> executed it wrong". Report how you ran it and what message(s)
> >> you saw. Remember - I can't see your screen!
> >>
> >>
> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> news:3279AC87-247B-4198-960B-E420AD8A3DA8@microsoft.com...
> >> > Do you have the proper syntax since I must've executed it wrong.
> >> >
> >> > thanks,
> >> > b.
> >> >
> >> > "Pegasus (MVP)" wrote:
> >> >
> >> >> This batch file will rename the specified file but only if its
> >> >> size exceeds 50 kBytes:
> >> >>
> >> >> 01. @echo off
> >> >> 02. if "%*"=="" goto Error
> >> >> 03. if not exist "%*" goto Error
> >> >> 04.
> >> >> 05. set limit=50000
> >> >> 06. for /F %%a in ('echo %*') do if %%~za LSS %limit% goto error
> >> >> 07. for /F "tokens=2" %%a in ('echo %date%') do set MyDate=%%a
> >> >> 08. echo ren "%*" "batch-%MyDate:/=%.*
> >> >> 09. goto :eof
> >> >> 10.
> >> >> 11. :Error
> >> >> 12. echo.
> >> >> 13. echo No parameter given, or file does not exist,
> >> >> 14. echo or file size is less than 50 kBytes.
> >> >>
> >> >> Invoke the batch file with the name of the file to-be-renamed
> >> >> as a parameter. Do NOT surround the file name with double
> >> >> quotes.
> >> >>
> >> >> Remove the word "echo" in Line #08 to activate the batch file.
> >> >>
> >> >>
> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> >> news:87F0D5B0-763F-456B-999C-975D2850B1FC@microsoft.com...
> >> >> > There wouldn't be a file of the same name if it has the format:
> >> >> > "batch-mm-dd-yy.log". I don't know what the coding would be for the
> >> >> > size
> >> >> > which is why I posted the question. Basically, I would need the
> >> >> > batch
> >> >> > file
> >> >> > to rename the log file (ex: batch.log) to "batch-080508.log" (or
> >> >> > batch
> >> >> > +
> >> >> > <date of renaming>.log) once the file reaches 50MB in size. If you
> >> >> > can
> >> >> > tell
> >> >> > me the syntax for the file size and the date, I can write the batch
> >> >> > unless
> >> >> > there's a better way of writing the batch file.
> >> >> >
> >> >> > thanks,
> >> >> > b.
> >> >> >
> >> >> > "Pegasus (MVP)" wrote:
> >> >> >
> >> >> >>
> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> >> >> news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
> >> >> >> >I need to create a "simple" batch file that will not only rename a
> >> >> >> >specified
> >> >> >> > file to the date it was renamed (example: batch.log to
> >> >> >> > batch-080508.log)
> >> >> >> > but
> >> >> >> > also based on the file size limit (example: if file size is less
> >> >> >> > than
> >> >> >> > 50MB,
> >> >> >> > please rename batch.log to batch-080508.log)
> >> >> >> >
> >> >> >> > Thanks,
> >> >> >> > B.
> >> >> >>
> >> >> >> Assuming that "batch-080508.log" means "batch-mm-dd-yy.log,
> >> >> >> where is the coding for the size? What if the file is > 50 MBytes?
> >> >> >> Less than 10 MBytes? What if a file of the same name already
> >> >> >> exists? You need to be nail down these issues before you can
> >> >> >> start writing a batch file.
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #10 (permalink)  
Old 10-17-2008, 01:43 AM
Pegasus \(MVP\)
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size

Yes, but why don't you give it a try? It will take less time than
asking here and waiting for answer!


"Brandon" <Brandon@discussions.microsoft.com> wrote in message
news:5438F7FC-36E4-48D1-B620-337FC40D81C1@microsoft.com...
> Is it as easy as putting the stop command within the batch file, and the
> start command at the end??
>
>
> "Pegasus (MVP)" wrote:
>
>> Yes, it's possible.
>> net stop "Name of Service"
>> net start "Name of Service"
>>
>> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> news:05F62B46-435B-4536-A05B-0AFD3AEE0FA8@microsoft.com...
>> > You can't see my screen?? Just kidding! You're right, I'll try to
>> > duplicate the process in detail for you and what I ran into.
>> >
>> > I did get it to work using the syntax you provided. Thanks! Now, I
>> > need
>> > the
>> > batch file (if possible) to stop a service, run the batch, then start
>> > the
>> > service. Is this possible??
>> >
>> > thanks again,
>> > b.
>> >
>> > "Pegasus (MVP)" wrote:
>> >
>> >> c:\Windows\MyBatchFile.bat d:\My Files\SomeEvent.log
>> >>
>> >> When you have a problem, don't just write "I must have
>> >> executed it wrong". Report how you ran it and what message(s)
>> >> you saw. Remember - I can't see your screen!
>> >>
>> >>
>> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> >> news:3279AC87-247B-4198-960B-E420AD8A3DA8@microsoft.com...
>> >> > Do you have the proper syntax since I must've executed it wrong.
>> >> >
>> >> > thanks,
>> >> > b.
>> >> >
>> >> > "Pegasus (MVP)" wrote:
>> >> >
>> >> >> This batch file will rename the specified file but only if its
>> >> >> size exceeds 50 kBytes:
>> >> >>
>> >> >> 01. @echo off
>> >> >> 02. if "%*"=="" goto Error
>> >> >> 03. if not exist "%*" goto Error
>> >> >> 04.
>> >> >> 05. set limit=50000
>> >> >> 06. for /F %%a in ('echo %*') do if %%~za LSS %limit% goto error
>> >> >> 07. for /F "tokens=2" %%a in ('echo %date%') do set MyDate=%%a
>> >> >> 08. echo ren "%*" "batch-%MyDate:/=%.*
>> >> >> 09. goto :eof
>> >> >> 10.
>> >> >> 11. :Error
>> >> >> 12. echo.
>> >> >> 13. echo No parameter given, or file does not exist,
>> >> >> 14. echo or file size is less than 50 kBytes.
>> >> >>
>> >> >> Invoke the batch file with the name of the file to-be-renamed
>> >> >> as a parameter. Do NOT surround the file name with double
>> >> >> quotes.
>> >> >>
>> >> >> Remove the word "echo" in Line #08 to activate the batch file.
>> >> >>
>> >> >>
>> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> >> >> news:87F0D5B0-763F-456B-999C-975D2850B1FC@microsoft.com...
>> >> >> > There wouldn't be a file of the same name if it has the format:
>> >> >> > "batch-mm-dd-yy.log". I don't know what the coding would be for
>> >> >> > the
>> >> >> > size
>> >> >> > which is why I posted the question. Basically, I would need the
>> >> >> > batch
>> >> >> > file
>> >> >> > to rename the log file (ex: batch.log) to "batch-080508.log" (or
>> >> >> > batch
>> >> >> > +
>> >> >> > <date of renaming>.log) once the file reaches 50MB in size. If
>> >> >> > you
>> >> >> > can
>> >> >> > tell
>> >> >> > me the syntax for the file size and the date, I can write the
>> >> >> > batch
>> >> >> > unless
>> >> >> > there's a better way of writing the batch file.
>> >> >> >
>> >> >> > thanks,
>> >> >> > b.
>> >> >> >
>> >> >> > "Pegasus (MVP)" wrote:
>> >> >> >
>> >> >> >>
>> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> >> >> >> news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
>> >> >> >> >I need to create a "simple" batch file that will not only
>> >> >> >> >rename a
>> >> >> >> >specified
>> >> >> >> > file to the date it was renamed (example: batch.log to
>> >> >> >> > batch-080508.log)
>> >> >> >> > but
>> >> >> >> > also based on the file size limit (example: if file size is
>> >> >> >> > less
>> >> >> >> > than
>> >> >> >> > 50MB,
>> >> >> >> > please rename batch.log to batch-080508.log)
>> >> >> >> >
>> >> >> >> > Thanks,
>> >> >> >> > B.
>> >> >> >>
>> >> >> >> Assuming that "batch-080508.log" means "batch-mm-dd-yy.log,
>> >> >> >> where is the coding for the size? What if the file is > 50
>> >> >> >> MBytes?
>> >> >> >> Less than 10 MBytes? What if a file of the same name already
>> >> >> >> exists? You need to be nail down these issues before you can
>> >> >> >> start writing a batch file.
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>

>>
>>
>>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #11 (permalink)  
Old 10-17-2008, 01:43 AM
Brandon
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size

I DID try it, before I sent the last email, but it didn't work. Is there a
special way of entering it in the batch file then how you would type it on
the command line??


"Pegasus (MVP)" wrote:

> Yes, but why don't you give it a try? It will take less time than
> asking here and waiting for answer!
>
>
> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> news:5438F7FC-36E4-48D1-B620-337FC40D81C1@microsoft.com...
> > Is it as easy as putting the stop command within the batch file, and the
> > start command at the end??
> >
> >
> > "Pegasus (MVP)" wrote:
> >
> >> Yes, it's possible.
> >> net stop "Name of Service"
> >> net start "Name of Service"
> >>
> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> news:05F62B46-435B-4536-A05B-0AFD3AEE0FA8@microsoft.com...
> >> > You can't see my screen?? Just kidding! You're right, I'll try to
> >> > duplicate the process in detail for you and what I ran into.
> >> >
> >> > I did get it to work using the syntax you provided. Thanks! Now, I
> >> > need
> >> > the
> >> > batch file (if possible) to stop a service, run the batch, then start
> >> > the
> >> > service. Is this possible??
> >> >
> >> > thanks again,
> >> > b.
> >> >
> >> > "Pegasus (MVP)" wrote:
> >> >
> >> >> c:\Windows\MyBatchFile.bat d:\My Files\SomeEvent.log
> >> >>
> >> >> When you have a problem, don't just write "I must have
> >> >> executed it wrong". Report how you ran it and what message(s)
> >> >> you saw. Remember - I can't see your screen!
> >> >>
> >> >>
> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> >> news:3279AC87-247B-4198-960B-E420AD8A3DA8@microsoft.com...
> >> >> > Do you have the proper syntax since I must've executed it wrong.
> >> >> >
> >> >> > thanks,
> >> >> > b.
> >> >> >
> >> >> > "Pegasus (MVP)" wrote:
> >> >> >
> >> >> >> This batch file will rename the specified file but only if its
> >> >> >> size exceeds 50 kBytes:
> >> >> >>
> >> >> >> 01. @echo off
> >> >> >> 02. if "%*"=="" goto Error
> >> >> >> 03. if not exist "%*" goto Error
> >> >> >> 04.
> >> >> >> 05. set limit=50000
> >> >> >> 06. for /F %%a in ('echo %*') do if %%~za LSS %limit% goto error
> >> >> >> 07. for /F "tokens=2" %%a in ('echo %date%') do set MyDate=%%a
> >> >> >> 08. echo ren "%*" "batch-%MyDate:/=%.*
> >> >> >> 09. goto :eof
> >> >> >> 10.
> >> >> >> 11. :Error
> >> >> >> 12. echo.
> >> >> >> 13. echo No parameter given, or file does not exist,
> >> >> >> 14. echo or file size is less than 50 kBytes.
> >> >> >>
> >> >> >> Invoke the batch file with the name of the file to-be-renamed
> >> >> >> as a parameter. Do NOT surround the file name with double
> >> >> >> quotes.
> >> >> >>
> >> >> >> Remove the word "echo" in Line #08 to activate the batch file.
> >> >> >>
> >> >> >>
> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> >> >> news:87F0D5B0-763F-456B-999C-975D2850B1FC@microsoft.com...
> >> >> >> > There wouldn't be a file of the same name if it has the format:
> >> >> >> > "batch-mm-dd-yy.log". I don't know what the coding would be for
> >> >> >> > the
> >> >> >> > size
> >> >> >> > which is why I posted the question. Basically, I would need the
> >> >> >> > batch
> >> >> >> > file
> >> >> >> > to rename the log file (ex: batch.log) to "batch-080508.log" (or
> >> >> >> > batch
> >> >> >> > +
> >> >> >> > <date of renaming>.log) once the file reaches 50MB in size. If
> >> >> >> > you
> >> >> >> > can
> >> >> >> > tell
> >> >> >> > me the syntax for the file size and the date, I can write the
> >> >> >> > batch
> >> >> >> > unless
> >> >> >> > there's a better way of writing the batch file.
> >> >> >> >
> >> >> >> > thanks,
> >> >> >> > b.
> >> >> >> >
> >> >> >> > "Pegasus (MVP)" wrote:
> >> >> >> >
> >> >> >> >>
> >> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> >> >> >> news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
> >> >> >> >> >I need to create a "simple" batch file that will not only
> >> >> >> >> >rename a
> >> >> >> >> >specified
> >> >> >> >> > file to the date it was renamed (example: batch.log to
> >> >> >> >> > batch-080508.log)
> >> >> >> >> > but
> >> >> >> >> > also based on the file size limit (example: if file size is
> >> >> >> >> > less
> >> >> >> >> > than
> >> >> >> >> > 50MB,
> >> >> >> >> > please rename batch.log to batch-080508.log)
> >> >> >> >> >
> >> >> >> >> > Thanks,
> >> >> >> >> > B.
> >> >> >> >>
> >> >> >> >> Assuming that "batch-080508.log" means "batch-mm-dd-yy.log,
> >> >> >> >> where is the coding for the size? What if the file is > 50
> >> >> >> >> MBytes?
> >> >> >> >> Less than 10 MBytes? What if a file of the same name already
> >> >> >> >> exists? You need to be nail down these issues before you can
> >> >> >> >> start writing a batch file.
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #12 (permalink)  
Old 10-17-2008, 01:44 AM
Pegasus \(MVP\)
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size

No, it's the same. However, I suspect that you're running
your batch file from the Start/Run box. That's a bad idea -
it deprives you of any screen feedback you might get. Much
better to start a Command Prompt (Start / Run / cmd), then
running the batch file from there. Now you really see what's
going on!


"Brandon" <Brandon@discussions.microsoft.com> wrote in message
news:BE6AA937-CC40-4CFC-89B8-6482E373B132@microsoft.com...
>I DID try it, before I sent the last email, but it didn't work. Is there a
> special way of entering it in the batch file then how you would type it on
> the command line??
>
>
> "Pegasus (MVP)" wrote:
>
>> Yes, but why don't you give it a try? It will take less time than
>> asking here and waiting for answer!
>>
>>
>> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> news:5438F7FC-36E4-48D1-B620-337FC40D81C1@microsoft.com...
>> > Is it as easy as putting the stop command within the batch file, and
>> > the
>> > start command at the end??
>> >
>> >
>> > "Pegasus (MVP)" wrote:
>> >
>> >> Yes, it's possible.
>> >> net stop "Name of Service"
>> >> net start "Name of Service"
>> >>
>> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> >> news:05F62B46-435B-4536-A05B-0AFD3AEE0FA8@microsoft.com...
>> >> > You can't see my screen?? Just kidding! You're right, I'll try to
>> >> > duplicate the process in detail for you and what I ran into.
>> >> >
>> >> > I did get it to work using the syntax you provided. Thanks! Now, I
>> >> > need
>> >> > the
>> >> > batch file (if possible) to stop a service, run the batch, then
>> >> > start
>> >> > the
>> >> > service. Is this possible??
>> >> >
>> >> > thanks again,
>> >> > b.
>> >> >
>> >> > "Pegasus (MVP)" wrote:
>> >> >
>> >> >> c:\Windows\MyBatchFile.bat d:\My Files\SomeEvent.log
>> >> >>
>> >> >> When you have a problem, don't just write "I must have
>> >> >> executed it wrong". Report how you ran it and what message(s)
>> >> >> you saw. Remember - I can't see your screen!
>> >> >>
>> >> >>
>> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> >> >> news:3279AC87-247B-4198-960B-E420AD8A3DA8@microsoft.com...
>> >> >> > Do you have the proper syntax since I must've executed it wrong.
>> >> >> >
>> >> >> > thanks,
>> >> >> > b.
>> >> >> >
>> >> >> > "Pegasus (MVP)" wrote:
>> >> >> >
>> >> >> >> This batch file will rename the specified file but only if its
>> >> >> >> size exceeds 50 kBytes:
>> >> >> >>
>> >> >> >> 01. @echo off
>> >> >> >> 02. if "%*"=="" goto Error
>> >> >> >> 03. if not exist "%*" goto Error
>> >> >> >> 04.
>> >> >> >> 05. set limit=50000
>> >> >> >> 06. for /F %%a in ('echo %*') do if %%~za LSS %limit% goto error
>> >> >> >> 07. for /F "tokens=2" %%a in ('echo %date%') do set MyDate=%%a
>> >> >> >> 08. echo ren "%*" "batch-%MyDate:/=%.*
>> >> >> >> 09. goto :eof
>> >> >> >> 10.
>> >> >> >> 11. :Error
>> >> >> >> 12. echo.
>> >> >> >> 13. echo No parameter given, or file does not exist,
>> >> >> >> 14. echo or file size is less than 50 kBytes.
>> >> >> >>
>> >> >> >> Invoke the batch file with the name of the file to-be-renamed
>> >> >> >> as a parameter. Do NOT surround the file name with double
>> >> >> >> quotes.
>> >> >> >>
>> >> >> >> Remove the word "echo" in Line #08 to activate the batch file.
>> >> >> >>
>> >> >> >>
>> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> >> >> >> news:87F0D5B0-763F-456B-999C-975D2850B1FC@microsoft.com...
>> >> >> >> > There wouldn't be a file of the same name if it has the
>> >> >> >> > format:
>> >> >> >> > "batch-mm-dd-yy.log". I don't know what the coding would be
>> >> >> >> > for
>> >> >> >> > the
>> >> >> >> > size
>> >> >> >> > which is why I posted the question. Basically, I would need
>> >> >> >> > the
>> >> >> >> > batch
>> >> >> >> > file
>> >> >> >> > to rename the log file (ex: batch.log) to "batch-080508.log"
>> >> >> >> > (or
>> >> >> >> > batch
>> >> >> >> > +
>> >> >> >> > <date of renaming>.log) once the file reaches 50MB in size.
>> >> >> >> > If
>> >> >> >> > you
>> >> >> >> > can
>> >> >> >> > tell
>> >> >> >> > me the syntax for the file size and the date, I can write the
>> >> >> >> > batch
>> >> >> >> > unless
>> >> >> >> > there's a better way of writing the batch file.
>> >> >> >> >
>> >> >> >> > thanks,
>> >> >> >> > b.
>> >> >> >> >
>> >> >> >> > "Pegasus (MVP)" wrote:
>> >> >> >> >
>> >> >> >> >>
>> >> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in
>> >> >> >> >> message
>> >> >> >> >> news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
>> >> >> >> >> >I need to create a "simple" batch file that will not only
>> >> >> >> >> >rename a
>> >> >> >> >> >specified
>> >> >> >> >> > file to the date it was renamed (example: batch.log to
>> >> >> >> >> > batch-080508.log)
>> >> >> >> >> > but
>> >> >> >> >> > also based on the file size limit (example: if file size is
>> >> >> >> >> > less
>> >> >> >> >> > than
>> >> >> >> >> > 50MB,
>> >> >> >> >> > please rename batch.log to batch-080508.log)
>> >> >> >> >> >
>> >> >> >> >> > Thanks,
>> >> >> >> >> > B.
>> >> >> >> >>
>> >> >> >> >> Assuming that "batch-080508.log" means "batch-mm-dd-yy.log,
>> >> >> >> >> where is the coding for the size? What if the file is > 50
>> >> >> >> >> MBytes?
>> >> >> >> >> Less than 10 MBytes? What if a file of the same name already
>> >> >> >> >> exists? You need to be nail down these issues before you can
>> >> >> >> >> start writing a batch file.
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>

>>
>>
>>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #13 (permalink)  
Old 10-17-2008, 01:45 AM
Brandon
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size

Actually, I was running it from the cmd prompt the entire time. I only tried
it once from the Start|Run prompt cuz the cmd prompt wasn't working.


"Pegasus (MVP)" wrote:

> No, it's the same. However, I suspect that you're running
> your batch file from the Start/Run box. That's a bad idea -
> it deprives you of any screen feedback you might get. Much
> better to start a Command Prompt (Start / Run / cmd), then
> running the batch file from there. Now you really see what's
> going on!
>
>
> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> news:BE6AA937-CC40-4CFC-89B8-6482E373B132@microsoft.com...
> >I DID try it, before I sent the last email, but it didn't work. Is there a
> > special way of entering it in the batch file then how you would type it on
> > the command line??
> >
> >
> > "Pegasus (MVP)" wrote:
> >
> >> Yes, but why don't you give it a try? It will take less time than
> >> asking here and waiting for answer!
> >>
> >>
> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> news:5438F7FC-36E4-48D1-B620-337FC40D81C1@microsoft.com...
> >> > Is it as easy as putting the stop command within the batch file, and
> >> > the
> >> > start command at the end??
> >> >
> >> >
> >> > "Pegasus (MVP)" wrote:
> >> >
> >> >> Yes, it's possible.
> >> >> net stop "Name of Service"
> >> >> net start "Name of Service"
> >> >>
> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> >> news:05F62B46-435B-4536-A05B-0AFD3AEE0FA8@microsoft.com...
> >> >> > You can't see my screen?? Just kidding! You're right, I'll try to
> >> >> > duplicate the process in detail for you and what I ran into.
> >> >> >
> >> >> > I did get it to work using the syntax you provided. Thanks! Now, I
> >> >> > need
> >> >> > the
> >> >> > batch file (if possible) to stop a service, run the batch, then
> >> >> > start
> >> >> > the
> >> >> > service. Is this possible??
> >> >> >
> >> >> > thanks again,
> >> >> > b.
> >> >> >
> >> >> > "Pegasus (MVP)" wrote:
> >> >> >
> >> >> >> c:\Windows\MyBatchFile.bat d:\My Files\SomeEvent.log
> >> >> >>
> >> >> >> When you have a problem, don't just write "I must have
> >> >> >> executed it wrong". Report how you ran it and what message(s)
> >> >> >> you saw. Remember - I can't see your screen!
> >> >> >>
> >> >> >>
> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> >> >> news:3279AC87-247B-4198-960B-E420AD8A3DA8@microsoft.com...
> >> >> >> > Do you have the proper syntax since I must've executed it wrong.
> >> >> >> >
> >> >> >> > thanks,
> >> >> >> > b.
> >> >> >> >
> >> >> >> > "Pegasus (MVP)" wrote:
> >> >> >> >
> >> >> >> >> This batch file will rename the specified file but only if its
> >> >> >> >> size exceeds 50 kBytes:
> >> >> >> >>
> >> >> >> >> 01. @echo off
> >> >> >> >> 02. if "%*"=="" goto Error
> >> >> >> >> 03. if not exist "%*" goto Error
> >> >> >> >> 04.
> >> >> >> >> 05. set limit=50000
> >> >> >> >> 06. for /F %%a in ('echo %*') do if %%~za LSS %limit% goto error
> >> >> >> >> 07. for /F "tokens=2" %%a in ('echo %date%') do set MyDate=%%a
> >> >> >> >> 08. echo ren "%*" "batch-%MyDate:/=%.*
> >> >> >> >> 09. goto :eof
> >> >> >> >> 10.
> >> >> >> >> 11. :Error
> >> >> >> >> 12. echo.
> >> >> >> >> 13. echo No parameter given, or file does not exist,
> >> >> >> >> 14. echo or file size is less than 50 kBytes.
> >> >> >> >>
> >> >> >> >> Invoke the batch file with the name of the file to-be-renamed
> >> >> >> >> as a parameter. Do NOT surround the file name with double
> >> >> >> >> quotes.
> >> >> >> >>
> >> >> >> >> Remove the word "echo" in Line #08 to activate the batch file.
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> >> >> >> news:87F0D5B0-763F-456B-999C-975D2850B1FC@microsoft.com...
> >> >> >> >> > There wouldn't be a file of the same name if it has the
> >> >> >> >> > format:
> >> >> >> >> > "batch-mm-dd-yy.log". I don't know what the coding would be
> >> >> >> >> > for
> >> >> >> >> > the
> >> >> >> >> > size
> >> >> >> >> > which is why I posted the question. Basically, I would need
> >> >> >> >> > the
> >> >> >> >> > batch
> >> >> >> >> > file
> >> >> >> >> > to rename the log file (ex: batch.log) to "batch-080508.log"
> >> >> >> >> > (or
> >> >> >> >> > batch
> >> >> >> >> > +
> >> >> >> >> > <date of renaming>.log) once the file reaches 50MB in size.
> >> >> >> >> > If
> >> >> >> >> > you
> >> >> >> >> > can
> >> >> >> >> > tell
> >> >> >> >> > me the syntax for the file size and the date, I can write the
> >> >> >> >> > batch
> >> >> >> >> > unless
> >> >> >> >> > there's a better way of writing the batch file.
> >> >> >> >> >
> >> >> >> >> > thanks,
> >> >> >> >> > b.
> >> >> >> >> >
> >> >> >> >> > "Pegasus (MVP)" wrote:
> >> >> >> >> >
> >> >> >> >> >>
> >> >> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in
> >> >> >> >> >> message
> >> >> >> >> >> news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
> >> >> >> >> >> >I need to create a "simple" batch file that will not only
> >> >> >> >> >> >rename a
> >> >> >> >> >> >specified
> >> >> >> >> >> > file to the date it was renamed (example: batch.log to
> >> >> >> >> >> > batch-080508.log)
> >> >> >> >> >> > but
> >> >> >> >> >> > also based on the file size limit (example: if file size is
> >> >> >> >> >> > less
> >> >> >> >> >> > than
> >> >> >> >> >> > 50MB,
> >> >> >> >> >> > please rename batch.log to batch-080508.log)
> >> >> >> >> >> >
> >> >> >> >> >> > Thanks,
> >> >> >> >> >> > B.
> >> >> >> >> >>
> >> >> >> >> >> Assuming that "batch-080508.log" means "batch-mm-dd-yy.log,
> >> >> >> >> >> where is the coding for the size? What if the file is > 50
> >> >> >> >> >> MBytes?
> >> >> >> >> >> Less than 10 MBytes? What if a file of the same name already
> >> >> >> >> >> exists? You need to be nail down these issues before you can
> >> >> >> >> >> start writing a batch file.
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #14 (permalink)  
Old 10-17-2008, 01:45 AM
Pegasus \(MVP\)
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size

Here we go again: "Cuz the command prompt wasn't working".
Doesn't tell me anything, return to sender.


"Brandon" <Brandon@discussions.microsoft.com> wrote in message
news:72BC1694-3AEC-4FB6-A372-9D4B5C2C0BB5@microsoft.com...
> Actually, I was running it from the cmd prompt the entire time. I only
> tried
> it once from the Start|Run prompt cuz the cmd prompt wasn't working.
>
>
> "Pegasus (MVP)" wrote:
>
>> No, it's the same. However, I suspect that you're running
>> your batch file from the Start/Run box. That's a bad idea -
>> it deprives you of any screen feedback you might get. Much
>> better to start a Command Prompt (Start / Run / cmd), then
>> running the batch file from there. Now you really see what's
>> going on!
>>
>>
>> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> news:BE6AA937-CC40-4CFC-89B8-6482E373B132@microsoft.com...
>> >I DID try it, before I sent the last email, but it didn't work. Is
>> >there a
>> > special way of entering it in the batch file then how you would type it
>> > on
>> > the command line??
>> >
>> >
>> > "Pegasus (MVP)" wrote:
>> >
>> >> Yes, but why don't you give it a try? It will take less time than
>> >> asking here and waiting for answer!
>> >>
>> >>
>> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> >> news:5438F7FC-36E4-48D1-B620-337FC40D81C1@microsoft.com...
>> >> > Is it as easy as putting the stop command within the batch file, and
>> >> > the
>> >> > start command at the end??
>> >> >
>> >> >
>> >> > "Pegasus (MVP)" wrote:
>> >> >
>> >> >> Yes, it's possible.
>> >> >> net stop "Name of Service"
>> >> >> net start "Name of Service"
>> >> >>
>> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> >> >> news:05F62B46-435B-4536-A05B-0AFD3AEE0FA8@microsoft.com...
>> >> >> > You can't see my screen?? Just kidding! You're right, I'll try
>> >> >> > to
>> >> >> > duplicate the process in detail for you and what I ran into.
>> >> >> >
>> >> >> > I did get it to work using the syntax you provided. Thanks! Now,
>> >> >> > I
>> >> >> > need
>> >> >> > the
>> >> >> > batch file (if possible) to stop a service, run the batch, then
>> >> >> > start
>> >> >> > the
>> >> >> > service. Is this possible??
>> >> >> >
>> >> >> > thanks again,
>> >> >> > b.
>> >> >> >
>> >> >> > "Pegasus (MVP)" wrote:
>> >> >> >
>> >> >> >> c:\Windows\MyBatchFile.bat d:\My Files\SomeEvent.log
>> >> >> >>
>> >> >> >> When you have a problem, don't just write "I must have
>> >> >> >> executed it wrong". Report how you ran it and what message(s)
>> >> >> >> you saw. Remember - I can't see your screen!
>> >> >> >>
>> >> >> >>
>> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
>> >> >> >> news:3279AC87-247B-4198-960B-E420AD8A3DA8@microsoft.com...
>> >> >> >> > Do you have the proper syntax since I must've executed it
>> >> >> >> > wrong.
>> >> >> >> >
>> >> >> >> > thanks,
>> >> >> >> > b.
>> >> >> >> >
>> >> >> >> > "Pegasus (MVP)" wrote:
>> >> >> >> >
>> >> >> >> >> This batch file will rename the specified file but only if
>> >> >> >> >> its
>> >> >> >> >> size exceeds 50 kBytes:
>> >> >> >> >>
>> >> >> >> >> 01. @echo off
>> >> >> >> >> 02. if "%*"=="" goto Error
>> >> >> >> >> 03. if not exist "%*" goto Error
>> >> >> >> >> 04.
>> >> >> >> >> 05. set limit=50000
>> >> >> >> >> 06. for /F %%a in ('echo %*') do if %%~za LSS %limit% goto
>> >> >> >> >> error
>> >> >> >> >> 07. for /F "tokens=2" %%a in ('echo %date%') do set
>> >> >> >> >> MyDate=%%a
>> >> >> >> >> 08. echo ren "%*" "batch-%MyDate:/=%.*
>> >> >> >> >> 09. goto :eof
>> >> >> >> >> 10.
>> >> >> >> >> 11. :Error
>> >> >> >> >> 12. echo.
>> >> >> >> >> 13. echo No parameter given, or file does not exist,
>> >> >> >> >> 14. echo or file size is less than 50 kBytes.
>> >> >> >> >>
>> >> >> >> >> Invoke the batch file with the name of the file to-be-renamed
>> >> >> >> >> as a parameter. Do NOT surround the file name with double
>> >> >> >> >> quotes.
>> >> >> >> >>
>> >> >> >> >> Remove the word "echo" in Line #08 to activate the batch
>> >> >> >> >> file.
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in
>> >> >> >> >> message
>> >> >> >> >> news:87F0D5B0-763F-456B-999C-975D2850B1FC@microsoft.com...
>> >> >> >> >> > There wouldn't be a file of the same name if it has the
>> >> >> >> >> > format:
>> >> >> >> >> > "batch-mm-dd-yy.log". I don't know what the coding would
>> >> >> >> >> > be
>> >> >> >> >> > for
>> >> >> >> >> > the
>> >> >> >> >> > size
>> >> >> >> >> > which is why I posted the question. Basically, I would
>> >> >> >> >> > need
>> >> >> >> >> > the
>> >> >> >> >> > batch
>> >> >> >> >> > file
>> >> >> >> >> > to rename the log file (ex: batch.log) to
>> >> >> >> >> > "batch-080508.log"
>> >> >> >> >> > (or
>> >> >> >> >> > batch
>> >> >> >> >> > +
>> >> >> >> >> > <date of renaming>.log) once the file reaches 50MB in size.
>> >> >> >> >> > If
>> >> >> >> >> > you
>> >> >> >> >> > can
>> >> >> >> >> > tell
>> >> >> >> >> > me the syntax for the file size and the date, I can write
>> >> >> >> >> > the
>> >> >> >> >> > batch
>> >> >> >> >> > unless
>> >> >> >> >> > there's a better way of writing the batch file.
>> >> >> >> >> >
>> >> >> >> >> > thanks,
>> >> >> >> >> > b.
>> >> >> >> >> >
>> >> >> >> >> > "Pegasus (MVP)" wrote:
>> >> >> >> >> >
>> >> >> >> >> >>
>> >> >> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in
>> >> >> >> >> >> message
>> >> >> >> >> >> news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
>> >> >> >> >> >> >I need to create a "simple" batch file that will not only
>> >> >> >> >> >> >rename a
>> >> >> >> >> >> >specified
>> >> >> >> >> >> > file to the date it was renamed (example: batch.log to
>> >> >> >> >> >> > batch-080508.log)
>> >> >> >> >> >> > but
>> >> >> >> >> >> > also based on the file size limit (example: if file size
>> >> >> >> >> >> > is
>> >> >> >> >> >> > less
>> >> >> >> >> >> > than
>> >> >> >> >> >> > 50MB,
>> >> >> >> >> >> > please rename batch.log to batch-080508.log)
>> >> >> >> >> >> >
>> >> >> >> >> >> > Thanks,
>> >> >> >> >> >> > B.
>> >> >> >> >> >>
>> >> >> >> >> >> Assuming that "batch-080508.log" means
>> >> >> >> >> >> "batch-mm-dd-yy.log,
>> >> >> >> >> >> where is the coding for the size? What if the file is > 50
>> >> >> >> >> >> MBytes?
>> >> >> >> >> >> Less than 10 MBytes? What if a file of the same name
>> >> >> >> >> >> already
>> >> >> >> >> >> exists? You need to be nail down these issues before you
>> >> >> >> >> >> can
>> >> >> >> >> >> start writing a batch file.
>> >> >> >> >> >>
>> >> >> >> >> >>
>> >> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>

>>
>>
>>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #15 (permalink)  
Old 10-17-2008, 01:45 AM
Brandon
Newsgroup Contributor
 
Posts: n/a
Re: Need Batch file to rename file based on file size

That wasn't vague. I responded to your last email indicating that it would be
better to run from the cmd prompt. I indicated that I did try that the
entire time, BEFORE I tried the Start|Run prompt. Basically, it didn't work
from either prompt.

"Pegasus (MVP)" wrote:

> Here we go again: "Cuz the command prompt wasn't working".
> Doesn't tell me anything, return to sender.
>
>
> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> news:72BC1694-3AEC-4FB6-A372-9D4B5C2C0BB5@microsoft.com...
> > Actually, I was running it from the cmd prompt the entire time. I only
> > tried
> > it once from the Start|Run prompt cuz the cmd prompt wasn't working.
> >
> >
> > "Pegasus (MVP)" wrote:
> >
> >> No, it's the same. However, I suspect that you're running
> >> your batch file from the Start/Run box. That's a bad idea -
> >> it deprives you of any screen feedback you might get. Much
> >> better to start a Command Prompt (Start / Run / cmd), then
> >> running the batch file from there. Now you really see what's
> >> going on!
> >>
> >>
> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> news:BE6AA937-CC40-4CFC-89B8-6482E373B132@microsoft.com...
> >> >I DID try it, before I sent the last email, but it didn't work. Is
> >> >there a
> >> > special way of entering it in the batch file then how you would type it
> >> > on
> >> > the command line??
> >> >
> >> >
> >> > "Pegasus (MVP)" wrote:
> >> >
> >> >> Yes, but why don't you give it a try? It will take less time than
> >> >> asking here and waiting for answer!
> >> >>
> >> >>
> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> >> news:5438F7FC-36E4-48D1-B620-337FC40D81C1@microsoft.com...
> >> >> > Is it as easy as putting the stop command within the batch file, and
> >> >> > the
> >> >> > start command at the end??
> >> >> >
> >> >> >
> >> >> > "Pegasus (MVP)" wrote:
> >> >> >
> >> >> >> Yes, it's possible.
> >> >> >> net stop "Name of Service"
> >> >> >> net start "Name of Service"
> >> >> >>
> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> >> >> news:05F62B46-435B-4536-A05B-0AFD3AEE0FA8@microsoft.com...
> >> >> >> > You can't see my screen?? Just kidding! You're right, I'll try
> >> >> >> > to
> >> >> >> > duplicate the process in detail for you and what I ran into.
> >> >> >> >
> >> >> >> > I did get it to work using the syntax you provided. Thanks! Now,
> >> >> >> > I
> >> >> >> > need
> >> >> >> > the
> >> >> >> > batch file (if possible) to stop a service, run the batch, then
> >> >> >> > start
> >> >> >> > the
> >> >> >> > service. Is this possible??
> >> >> >> >
> >> >> >> > thanks again,
> >> >> >> > b.
> >> >> >> >
> >> >> >> > "Pegasus (MVP)" wrote:
> >> >> >> >
> >> >> >> >> c:\Windows\MyBatchFile.bat d:\My Files\SomeEvent.log
> >> >> >> >>
> >> >> >> >> When you have a problem, don't just write "I must have
> >> >> >> >> executed it wrong". Report how you ran it and what message(s)
> >> >> >> >> you saw. Remember - I can't see your screen!
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in message
> >> >> >> >> news:3279AC87-247B-4198-960B-E420AD8A3DA8@microsoft.com...
> >> >> >> >> > Do you have the proper syntax since I must've executed it
> >> >> >> >> > wrong.
> >> >> >> >> >
> >> >> >> >> > thanks,
> >> >> >> >> > b.
> >> >> >> >> >
> >> >> >> >> > "Pegasus (MVP)" wrote:
> >> >> >> >> >
> >> >> >> >> >> This batch file will rename the specified file but only if
> >> >> >> >> >> its
> >> >> >> >> >> size exceeds 50 kBytes:
> >> >> >> >> >>
> >> >> >> >> >> 01. @echo off
> >> >> >> >> >> 02. if "%*"=="" goto Error
> >> >> >> >> >> 03. if not exist "%*" goto Error
> >> >> >> >> >> 04.
> >> >> >> >> >> 05. set limit=50000
> >> >> >> >> >> 06. for /F %%a in ('echo %*') do if %%~za LSS %limit% goto
> >> >> >> >> >> error
> >> >> >> >> >> 07. for /F "tokens=2" %%a in ('echo %date%') do set
> >> >> >> >> >> MyDate=%%a
> >> >> >> >> >> 08. echo ren "%*" "batch-%MyDate:/=%.*
> >> >> >> >> >> 09. goto :eof
> >> >> >> >> >> 10.
> >> >> >> >> >> 11. :Error
> >> >> >> >> >> 12. echo.
> >> >> >> >> >> 13. echo No parameter given, or file does not exist,
> >> >> >> >> >> 14. echo or file size is less than 50 kBytes.
> >> >> >> >> >>
> >> >> >> >> >> Invoke the batch file with the name of the file to-be-renamed
> >> >> >> >> >> as a parameter. Do NOT surround the file name with double
> >> >> >> >> >> quotes.
> >> >> >> >> >>
> >> >> >> >> >> Remove the word "echo" in Line #08 to activate the batch
> >> >> >> >> >> file.
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in
> >> >> >> >> >> message
> >> >> >> >> >> news:87F0D5B0-763F-456B-999C-975D2850B1FC@microsoft.com...
> >> >> >> >> >> > There wouldn't be a file of the same name if it has the
> >> >> >> >> >> > format:
> >> >> >> >> >> > "batch-mm-dd-yy.log". I don't know what the coding would
> >> >> >> >> >> > be
> >> >> >> >> >> > for
> >> >> >> >> >> > the
> >> >> >> >> >> > size
> >> >> >> >> >> > which is why I posted the question. Basically, I would
> >> >> >> >> >> > need
> >> >> >> >> >> > the
> >> >> >> >> >> > batch
> >> >> >> >> >> > file
> >> >> >> >> >> > to rename the log file (ex: batch.log) to
> >> >> >> >> >> > "batch-080508.log"
> >> >> >> >> >> > (or
> >> >> >> >> >> > batch
> >> >> >> >> >> > +
> >> >> >> >> >> > <date of renaming>.log) once the file reaches 50MB in size.
> >> >> >> >> >> > If
> >> >> >> >> >> > you
> >> >> >> >> >> > can
> >> >> >> >> >> > tell
> >> >> >> >> >> > me the syntax for the file size and the date, I can write
> >> >> >> >> >> > the
> >> >> >> >> >> > batch
> >> >> >> >> >> > unless
> >> >> >> >> >> > there's a better way of writing the batch file.
> >> >> >> >> >> >
> >> >> >> >> >> > thanks,
> >> >> >> >> >> > b.
> >> >> >> >> >> >
> >> >> >> >> >> > "Pegasus (MVP)" wrote:
> >> >> >> >> >> >
> >> >> >> >> >> >>
> >> >> >> >> >> >> "Brandon" <Brandon@discussions.microsoft.com> wrote in
> >> >> >> >> >> >> message
> >> >> >> >> >> >> news:AB0C5031-E022-46BF-BBAD-66189E1C6B1D@microsoft.com...
> >> >> >> >> >> >> >I need to create a "simple" batch file that will not only
> >> >> >> >> >> >> >rename a
> >> >> >> >> >> >> >specified
> >> >> >> >> >> >> > file to the date it was renamed (example: batch.log to
> >> >> >> >> >> >> > batch-080508.log)
> >> >> >> >> >> >> > but
> >> >> >> >> >> >> > also based on the file size limit (example: if file size
> >> >> >> >> >> >> > is
> >> >> >> >> >> >> > less
> >> >> >> >> >> >> > than
> >> >> >> >> >> >> > 50MB,
> >> >> >> >> >> >> > please rename batch.log to batch-080508.log)
> >> >> >> >> >> >> >
> >> >> >> >> >> >> > Thanks,
> >> >> >> >> >> >> > B.
> >> >> >> >> >> >>
> >> >> >> >> >> >> Assuming that "batch-080508.log" means
> >> >> >> >> >> >> "batch-mm-dd-yy.log,
> >> >> >> >> >> >> where is the coding for the size? What if the file is > 50
> >> >> >> >> >> >> MBytes?
> >> >> >> >> >> >> Less than 10 MBytes? What if a file of the same name
> >> >> >> >> >> >> already
> >> >> >> >> >> >> exists? You need to be nail down these issues before you
> >> >> >> >> >> >> can
> >> >> >> >> >> >> start writing a batch file.
> >> >> >> >> >> >>
> >> >> >> >> >> >>
> >> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
rename batch file mas_pogi Windows XP 1 06-27-2008 02:40 AM
Rename a batch of file in sequence kaci Windows Vista 3 02-28-2008 05:30 AM
Batch file to rename with time and date alexanderd79@googlemail.com Windows XP 1 11-23-2007 05:00 AM
Rename in a batch file simonc Windows XP 4 01-04-2007 06:18 AM
Rename in a batch file simonc Windows XP 0 01-04-2007 06:18 AM


New To Technology Questions? Do You Need Help with Your Computer or Device? Do You Need Help with this site?

All times are GMT -8. The time now is 04:34 AM.


2003 - 2009 All Rights Reserved. Technology Questions

Search Engine Friendly URLs by vBSEO 3.3.0