1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

.bat files in WinXP

Discussion in 'Windows XP' started by Welshjim, 2004/08/01.

Thread Status:
Not open for further replies.
  1. 2004/08/01
    Welshjim

    Welshjim Inactive Thread Starter

    Joined:
    2002/01/07
    Messages:
    5,643
    Likes Received:
    0
    I am transferring files from a Win98 PC to a WinXP Pc.
    I have a simple .bat file that in Win98 creates a .txt file on the Desktop with a list of files in a folder. But it is not working in WinXP.
    Is this because .bat files do not work in WinXP? Or because I have messed something up?
    P.S. The text of the .bat file is
    dir %1>C:\Program Files\Desktop\jim.txt

    cls


    where C:\Program Files is the location of the .bat file.
     
  2. 2004/08/01
    Wobbler

    Wobbler Inactive

    Joined:
    2004/08/01
    Messages:
    8
    Likes Received:
    0
    Is it not just the fact that it's not valid to use a space like that ?
    If there is a space in the command it should be enclosed in quotes like:

    dir %1> "C:\Program Files\Desktop\jim.txt "
     

  3. to hide this advert.

  4. 2004/08/01
    dobhar Lifetime Subscription

    dobhar Inactive

    Joined:
    2002/05/24
    Messages:
    924
    Likes Received:
    3
    Hi Jim...

    To get to the Desktop you must use the "Documents and Settings\<username>\Desktop\jim.txt "

    So the string should look something like => dir %1> "C:\Docume~1\<username>\Desktop\Jim.txt " or dir %1> "C:\Documents and Settings\<username>\Desktop\Jim.txt "

    This is what I get when I use the following in a kent.bat file that I put in the root of C: Drive => dir %1> "C:\Documents and Settings\Kent\Desktop\Kent.txt "
    Volume in drive C is Local Disk
    Volume Serial Number is xxxx-xxxxx

    Directory of C:\

    10/16/2003 10:44 PM 0 AUTOEXEC.BAT
    07/31/2004 09:41 AM 270,213 BOC411.XVU
    07/06/2004 12:42 AM 62,501 BOClist.txt
    06/27/2004 12:26 AM 0 BOreport.txt
    06/13/2004 03:51 PM <DIR> CD_Burn
    10/16/2003 10:44 PM 0 CONFIG.SYS
    08/01/2004 11:36 PM 0 documents
    06/13/2004 01:29 PM <DIR> Documents and Settings
    07/12/2004 02:00 AM <DIR> Downloads
    07/12/2004 11:47 PM 560 hpfr5550.xml
    07/12/2004 11:47 PM 10,753 hph7150.log
    08/01/2004 11:44 PM 72 kent.bat
    05/08/2004 08:05 PM <DIR> PerfLogs
    08/01/2004 11:30 PM <DIR> Program Files
    06/28/2004 05:18 PM 6,116 sysinfo.txt
    07/02/2004 05:35 PM <DIR> temp
    08/01/2004 04:55 PM <DIR> WINDOWS
    10 File(s) 350,215 bytes
    9 Dir(s) 11,723,313,152 bytes free
     
    Last edited: 2004/08/01
  5. 2004/08/02
    dobhar Lifetime Subscription

    dobhar Inactive

    Joined:
    2002/05/24
    Messages:
    924
    Likes Received:
    3
    Hi Jim...

    One more thing, if you use the /s switch you will get all the subfolders...

    dir /a /o:nsedg /s %1> "C:\Documents and Settings\Kent\Desktop\Kent.txt "

    I now have a 3.5 mb txt file with a complete dir listing...
     
    Last edited: 2004/08/02
  6. 2004/08/02
    alanrf

    alanrf Well-Known Member

    Joined:
    2004/03/05
    Messages:
    282
    Likes Received:
    8
    The pathing tips are valid above but it is only necessary to enclose folder/file names with embedded spaces or decimal points in quotes, for example:

    C:\ "Documents and Settings "\Administrator\ "Start Menu "\

    or for a complete line

    D:\Mailbox\ "mercury.planet "\dilbert\*.* I:\ "%1 "\ "%2 "\Mailbox\ "mercury.planet "\dilbert\

    In this last example the %1 and %2 represent parameters fed to the batch file when it is invoked.

    Basically batch files continue to behave much as they have always done, albeit with a few improvements in the operation of the Command Prompt.
     
  7. 2004/08/02
    Welshjim

    Welshjim Inactive Thread Starter

    Joined:
    2002/01/07
    Messages:
    5,643
    Likes Received:
    0
    Thanks to all. I am pretty sure that the real solution was to use the quotation marks. (But I probably also had messed up the location in the transfer process, so I also changed that as suggested.)
    Works fine now.
    Thanks for putting up with me as I learn XP.
     
    Last edited: 2004/08/02
Thread Status:
Not open for further replies.

Share This Page

  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.