Saved Bookmarks
| 1. |
Solve : Help requested with making a batch file? |
|
Answer» Quote one more than number of files I do not see why it is necessary to do this. @billrich, what i mean is , how does your MOD file names look like? Bill wrote: One more than number of files for command line argument. Quote from: SALMON Trout on July 26, 2009, 05:18:24 AM 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" Quote from: billrich on July 26, 2009, 06:43:09 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? Quote from: Salmon Trout on July 26, 2009, 06:47:05 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. 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 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.OK I agree. Quote from: gh0std0g74 on July 26, 2009, 06:24:45 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.Quote from: gh0std0g74 on July 26, 2009, 06:24:45 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:\>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:\> |
|