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

Author Topic: Help requested with making a batch file  (Read 16140 times)

0 Members and 1 Guest are viewing this topic.

Salmon Trout

  • Guest
Re: Help requested with making a batch file
« Reply #30 on: July 26, 2009, 05:18:24 AM »
Quote
one more than number of files

I do not see why it is necessary to do this.

gh0std0g74



    Apprentice

    Thanked: 37
    Re: Help requested with making a batch file
    « Reply #31 on: July 26, 2009, 06:24:45 AM »
    @billrich, what i mean is , how does your MOD file names look like?

    billrich

    • Guest
    Re: Help requested with making a batch file
    « Reply #32 on: July 26, 2009, 06:43:09 AM »
    Bill wrote:

    One more than number of files for command line argument.


    I do not see why it is necessary to do this.


    We don't know how many files Abbie Dorr, the original poster has to rename.

    Abbie Dorr wrote:

    "If I do it like this (MOD rename to MPG) then I can edit the all the movie to a complete movie which I then can save as Avi"

    Salmon Trout

    • Guest
    Re: Help requested with making a batch file
    « Reply #33 on: July 26, 2009, 06:47:05 AM »
    We don't know how many files AbbieDorr, the original poster has to nename.

    I know that!  ::) Did you see the words I quoted? I wanted to know why it is necessary to supply a parameter which is one more than the number of files. Why it can't be the same as the number of files?

    billrich

    • Guest
    Re: Help requested with making a batch file
    « Reply #34 on: July 26, 2009, 06:55:59 AM »
    I know that!  ::) Did you see the words I quoted? I wanted to know why it is necessary to supply a parameter which is one more than the number of files. Why it can't be the same as the number of files? Anyway, why not count them in the batch? In fact, why bother counting them at all?


    It was necessary because of the way I wrote my code.

    Hey, this not production code and we are not paid.

    My rename code works and is exactly what Abbie Dorr, the original poster ask for.   

    Salmon Trout

    • Guest
    Re: Help requested with making a batch file
    « Reply #35 on: July 26, 2009, 06:58:54 AM »
    OK point taken

    If you do this you can use the actual number from the command line

    Code: [Select]
    set /a c=-1

    but I thought the OP wanted leading zeroes

    billrich

    • Guest
    Re: Help requested with making a batch file
    « Reply #36 on: July 26, 2009, 07:09:10 AM »
    Code: [Select]
    [quote author=Salmon Trout link=topic=88363.msg593414#msg593414 date=1248613134]
    OK point taken

    If you do this you can use the actual number from the command line

     


    "But I thought the OP wanted leading zeroes"

    [/quote]

    Abbie Dorr, the original poster can easily add leading zeros to the name. I see no advantage of leading zeros.   We need to leave insignificant details to  Abbie Dorr.  Abbie should be able to do some of the work.

    Salmon Trout

    • Guest
    Re: Help requested with making a batch file
    « Reply #37 on: July 26, 2009, 07:11:06 AM »
    OK I agree.

    billrich

    • Guest
    Re: Help requested with making a batch file
    « Reply #38 on: July 26, 2009, 07:28:55 AM »
    @billrich, what i mean is , how does your MOD file names look like?

    My  test MOD file names looked like:

    C:\>type mov10.mod
    hello

    C:\>type mov1.mod
    hello

    The files only contained "Hello."   Only the name was important.
    « Last Edit: July 26, 2009, 08:40:35 AM by billrich »

    billrich

    • Guest
    Re: Help requested with making a batch file
    « Reply #39 on: July 26, 2009, 07:50:31 AM »
    @billrich, what I mean is , how does your MOD file names look like?

    To Ghost, Trout,  Abbie Dorr and All interested parties:
    ( copy command used here to save mov**.mod file. ren used in next post. )

    REM There are no leading zeros for 10 and above in file names.
    REM  Usage: mpgname 13 ( one more than number of files )



    REM  Usage: mpgname 13 ( one more than number of files )

    Code: [Select]
    @echo off

    set /a c=0
    :start

    set /a c+=1
    if %c% EQU %1 set /a c=0 && goto  begin

     if %C%  LSS 10 echo hello > mov0%c%.mod
    if %C%  GTR  9  echo hello > mov%c%.mod
    goto start


    :begin

    set /a c+=1
    if %c% EQU %1  goto end

    REM if %C%  LSS 10 ren mov0%c%.mod    Holiday0%c%.MPG
    REM if %C%  GTR  9 ren mov0%c%.mod    Holiday%c%.MPG
    if %C%  LSS 10 copy mov0%c%.mod    Holiday0%c%.MPG

    if %C%   GTR 10 copy mov%c%.mod    Holiday%c%.MPG

    REM copy was used to save MOD files for Ghost

    goto begin

    :end
    dir /b  mov*.mod
    dir /b  Hol*.mpg

    Output:

    C:\>mpgname.bat 13

    C:\>REM  Usage: mpgname 13 ( one more than number of files )
            1 file(s) copied.
            1 file(s) copied.
            1 file(s) copied.
            1 file(s) copied.
            1 file(s) copied.
            1 file(s) copied.
            1 file(s) copied.
            1 file(s) copied.
            1 file(s) copied.
            1 file(s) copied.
            1 file(s) copied.
    mov01.mod
    mov02.mod
    mov03.mod
    mov04.mod
    mov05.mod
    mov06.mod
    mov07.mod
    mov08.mod
    mov09.mod
    mov10.mod
    mov11.mod
    mov12.mod
    Holiday01.MPG
    Holiday02.MPG
    Holiday03.MPG
    Holiday04.MPG
    Holiday05.MPG
    Holiday06.MPG
    Holiday07.MPG
    Holiday08.MPG
    Holiday09.MPG
    Holiday11.MPG
    Holiday12.MPG
    C:\>
    « Last Edit: July 26, 2009, 11:47:00 AM by billrich »

    billrich

    • Guest
    Re: Help requested with making a batch file
    « Reply #40 on: July 26, 2009, 12:07:03 PM »
    The following code  uses ren and not copy.  The test  mov*.mod files were removed with ren. See the  test  mov*.mod files above post #39.

    REM  Usage: mpgname 13 ( one more than number of files )

    Code: [Select]
    @echo off

    setLocal EnableDelayedExpansion

    set /a c=o
    :begin

    set /a c+=1
    if %c% EQU %1  goto end

    if %C%  LSS 10 ren mov0%c%.mod    Holiday0%c%.MPG
    if %C%  GTR  9 ren mov%c%.mod    Holiday%c%.MPG

    goto begin

    :end
    dir /b  Hol*.mpg

    Output :

    C:\> nomodname.bat 13

    C:\>REM  Usage: mpgname 13 ( one more than number of files )
    Holiday01.MPG
    Holiday02.MPG
    Holiday03.MPG
    Holiday04.MPG
    Holiday05.MPG
    Holiday06.MPG
    Holiday07.MPG
    Holiday08.MPG
    Holiday09.MPG
    Holiday10.MPG
    Holiday11.MPG
    Holiday12.MPG
    C:\>
    « Last Edit: July 26, 2009, 12:40:43 PM by billrich »