Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: help with a .bat file  (Read 10053 times)

0 Members and 1 Guest are viewing this topic.

Salmon Trout

  • Guest
Re: help with a .bat file
« Reply #30 on: December 14, 2009, 12:50:29 PM »
Quote
if *_std.idx(

not sure what you think this will do?

Anyhow, I use this modified version (changed line in blue)


@echo off

set thisdir=%cd%

Echo Scanning subfolders

for /f "delims=" %%D in ('dir /b /ad') do (
       
        echo Entering subfolder: %%D
       
        cd /d "%%D"
        Echo Renaming *_std to *_std.mpg
       
        if exist *_std (
               
                for /f "delims=" %%S in ( ' dir /b *_std ^| find /v "_std.idx" ' ) do (
               
                        echo Renaming %%S to %%S.mpg
                       
                        ren "%%S" "%%S.mpg"
               
                )
               
        ) else (
       
                echo *_std : no files to process
       
        )
       
       
        Echo Renaming 2-* to 9-* to 02-* to 09-*
        for %%N in (2 3 4 5 6 7 8 9) do (
               
                if exist "%%N-*" (
                       
                        for /f "delims=" %%F in ('dir /b %%N-*') do (
                       
                                echo Renaming %%F to 0%%F
                               
                                ren "%%F" "0%%F"
                       
                        )
               
                ) else (
               
                        echo %%N-* :   no files to process
               
                )
       
        )
       
        cd /d %thisdir%

)   

pause

Salmon Trout

  • Guest
Re: help with a .bat file
« Reply #31 on: December 14, 2009, 12:51:32 PM »
then again, wouldn't this work?

Code: [Select]
@echo off

set thisdir=%cd%

Echo Scanning subfolders

for /f "delims=" %%D in ('dir /b /ad') do (
       
        echo Entering subfolder: %%D
       
        cd /d "%%D"
        Echo Renaming *_std to *_std.mpg
ren *_std *_std.mpg
Echo renaming 2 to 02
ren 2-* 02-*
ren 3-* 03-*
ren 4-* 04-*
ren 5-* 05-*
ren 6-* 06-*
ren 7-* 07-*
ren 8-* 08-*
ren 9-* 09-*

       
        cd /d %thisdir%

)   

pause

less informative

Why not give it a try?