1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Batch renaming and creating file : DOS

Discussion in 'DOS/Other' started by suBz3ro, Aug 9, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. suBz3ro

    suBz3ro Thread Starter

    Joined:
    Aug 9, 2006
    Messages:
    7
    thanks for the support.
    have problem while running the .bat script.

    @echo off
    for /f "delims=~" %%a in me.txt do copy noimage.png "%%a.png"

    error message appear.
    me.txt used was incorrent.

    my me.txt file look like this

    Nightwish - nemo
    nightwish - over hills and far away
    Nightwish - Sleeping Sun
    and so on.
     
  2. ChuckE

    ChuckE

    Joined:
    Aug 30, 2004
    Messages:
    2,311
    You forgot the parens ( and ).

    It should be:
    Code:
    @echo off
    for /f "delims=~" %%a in (me.txt) do copy noimage.png "%%a.png"
     
  3. suBz3ro

    suBz3ro Thread Starter

    Joined:
    Aug 9, 2006
    Messages:
    7
    thanks bro and others. its help!.
     
  4. ChuckE

    ChuckE

    Joined:
    Aug 30, 2004
    Messages:
    2,311
    If that resolves your issue, please mark this thread "Solved"
     
  5. dtech10

    dtech10

    Joined:
    Jan 31, 2003
    Messages:
    53
    Hi
    if there's spaces in your names text file try this

    @echo off
    for /f "tokens=*" %%a in (Names.dat) do copy Sample.png "%%a.png"
     
  6. ChuckE

    ChuckE

    Joined:
    Aug 30, 2004
    Messages:
    2,311
    So, you don't have to send a 2nd message. Just edit your input.

    It makes for an easier read, and understanding, if you just make the input right, rather than to tell someone what you forgot to do (and hope they know how to edit your 1st input).
     
  7. blaqDeaph

    blaqDeaph

    Joined:
    Nov 22, 2005
    Messages:
    869
    Just a quick question, why the delims=~, shouldnt the quotes do the job fine?
     
  8. ChuckE

    ChuckE

    Joined:
    Aug 30, 2004
    Messages:
    2,311
    The for /f is searching through each line of the named file, and parsing per token. A token is separate by the delimiters, which is defaulted to 'white space' (can be a series of the actual space character or a series of tabs). Since each line may be made of a number of words and as many (minus one, of course) spaces, you need to change that default delimiter to some other character, which I specified to the "~" character, or as dtech10 specified as "*"

    Either will work. I tend to avoid wildcard characters, because it can be troublesome in some parsing situations, but in this instance it is just as usable for a substitute character.

    The quotes you are looking at are used to keep the result all together in the renaming portion of that command.

    So, we are needing to deal with spaces in two points here.
    1) the delims keeps the spaces in the search process, and
    2) the quotes keep the spaces in the naming process.
     
  9. blaqDeaph

    blaqDeaph

    Joined:
    Nov 22, 2005
    Messages:
    869
    Cool, thanks for the replies guys!
     
  10. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/490704

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice