| 1. |
Solve : Append name of parent folders to the names of the files? |
|
Answer» Dias DE verano wrote: Bc, I fail to see what that has to do with my post, but alright. This thread has really degenerated. Bc, I'm trying to learn how to use the for loop. I have not seen any for loops from BC. I appreciate your help. BC had suggested more tags and information about the for loop so I suggested the for /? at command prompt. I TRY to be nice and I still receive many negative comments. My "for loop" was an excellent solution to the the copy and rename file names problem. What should I do to remain on this board? What does BC, Carbon and Dias de verano want me do? I feel you do not want to help me. Are my posts really that bad? Why is Dias de verano so cruel to new people? Do you want me to leave? From for /? at command prompt. Runs a specified command for each file in a set of files.Quote I try to be nice You hijacked another person's thread and made it about "you" and made many trollish posts.Code: [Select][quote author=billrich link=topic=78827.msg521043#msg521043 date=1237249761] BC had suggested more tags and information about the for loop so I suggested the for /? at command prompt. [/quote] That had absolutely nothing to do with what I meant. I meant, instead of all this: [quote author=billrich link=topic=78827.msg520596#msg520596 date=1237199880] C:\>type renamejpg.bat @echo off Rem run this batch file with 3 command line variables REM renamejpg.bat c:\new jpg 2009.January REM renamejpg.bat destination extension Portion of file name setlocal REM Copy *.%2 %1 Rem Must be in the directory where files are originally cd %1 for /f "tokens=*" %%a in ('dir /b *.%2') do ren "%%a" "%3.%%a" C:\>renamejpg.bat c:\new jpg 2009.January C:\>cd new C:\new>dir *.jpg Volume Serial Number is B8F2-4B99 Directory of C:\new 09/24/2008 09:07 PM 22,033 2009.January.piper.jpg [b]08/04/2004 07:00 AM 57,925 2009.January.Purple flower.jpg[/b] 08/04/2004 07:00 AM 44,190 2009.January.Radiance.jpg [b]08/04/2004 07:00 AM 81,433 2009.January.Red moon desert.jpg[/b] 12/03/2008 07:07 PM 58,551 2009.January.redflower.jpg 05/08/2008 07:47 PM 63,784 2009.January.Slide2.jpg 05/08/2008 07:48 PM 41,097 2009.January.Slide4.jpg 05/09/2008 07:10 AM 42,105 2009.January.Slide6.jpg 05/09/2008 07:11 AM 51,122 2009.January.Slide8.jpg 05/09/2008 07:12 AM 55,696 2009.January.Slide9.jpg 08/04/2004 07:00 AM 73,159 2009.January.Tulips.jpg 08/04/2004 07:00 AM 37,246 2009.January.Wind.jpg 08/22/2008 10:17 AM 8,165 2009.January.wolf3.jpg 31 File(s) 2,169,842 bytes C:\new> [/quote] use this: [code] @echo off Rem run this batch file with 3 command line variables REM renamejpg.bat c:\new jpg 2009.January REM renamejpg.bat destination extension Portion of file name setlocal REM Copy *.%2 %1 Rem Must be in the directory where files are originally cd %1 for /f "tokens=*" %%a in ('dir /b *.%2') do ren "%%a" "%3.%%a" IE a code tag; the forum has a lot of useful bbcode tags that work wonderfully. Quote
isn't two Do...Loops Enough? regardless of which, I'm not particularly good with the new command line extensions; I stopped using batch programming extensively before I switched from windows 3.1, so I haven't really researched all the new stuff that can be done with it. I can use For quite well for it's original specs, but I haven't had time to sufficiently learn the new nuances added with CMD. I have however learned not to say stuff is impossible in batch, because the MOMENT I say that, and provide a VBScript solution Dias has a much shorter Batch program that does the same thing ... and even with VBScript I keep trying to use left$ Right$ Mid$ etc, when in fact VBScript has no notion of any type other then variant, and thus there is no $ suffix on any string manipulation functions. I still type them instinctively so I have to always check over my VBScript to make sure that I didn't let some money sneak in The fact of the matter is- this thread was solved when Dias posted his batch. your post could only suffice to confuse the OP since- as explained - it merely illustrated the REN command.[/code] |
|