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

Author Topic: xcopy can't tell a file from a directory?  (Read 34916 times)

0 Members and 1 Guest are viewing this topic.

nubia

    Topic Starter


    Rookie

    xcopy can't tell a file from a directory?
    « on: August 03, 2007, 09:09:38 PM »
    Hello-
    I'm extremely new to DOS and Batch files, so please bear with me.
    I'm using windows XP and have created a batch file to move files and directories from one directory to another. I am using the command "XCOPY".
    My file works, but I'm wondering if there is some way to let "XCOPY" know in advance that I wish to copy a File or a Directory, so I don't get prompted with
    "Is "c:/somedir" a File [F] or a Directory [D]?"
    Here is my code..
    Code: [Select]
    :: Resets Test
    cd ../..
    cd Test2
    rmdir c:\Test2\views /s
    del AppointmentsMap.xml
    del ContactsMap.xml
    del FileExtMap.xml
    del init.xml
    xcopy c:\Test1\views  c:\Test2\views /e
    xcopy c:\Test1\AppointmentsMap.xml c:\Test2\AppointmentsMap.xml /f
    xcopy c:\Test1\ContactsMap.xml c:\Test2\ContactsMap.xml /f
    xcopy c:\Test1\FileExtMap.xml  c:\Test2\FileExtMap.xml /f
    xcopy c:\Test1\init.xml c:\Test2\init.xml /f
    Thanking anyone for a clue as to how this might be done..
      ???

    contrex

    • Guest
    Re: xcopy can't tell a file from a directory?
    « Reply #1 on: August 03, 2007, 11:30:06 PM »
    If destination does not contain an existing directory and does not end with a backslash (\), xcopy prompts you with a message in the following format:

    Does destination specify a file name or directory name on the target

    (F = file, D = directory)?

    You can avoid this prompt by using the /i switch, in which case xcopy assumes the destination is a directory if the source is more than one file or a directory.

    nubia

      Topic Starter


      Rookie

      Re: xcopy can't tell a file from a directory?
      « Reply #2 on: August 04, 2007, 09:00:32 AM »
      Thank You for the tip re: the /i switch
      my code now reads..
      Code: [Select]
      :: Resets Test
      cd ../..
      cd Test2
      rmdir c:\Test2\views /s
      del AppointmentsMap.xml
      del ContactsMap.xml
      del FileExtMap.xml
      del proinit.xml
      xcopy c:\Test1\views  c:\Test2\views /i/e
      xcopy c:\Test1\AppointmentsMap.xml c:\Test2\AppointmentsMap.xml /f
      xcopy c:\Test1\ContactsMap.xml c:\Test2\ContactsMap.xml /f
      xcopy c:\Test1\FileExtMap.xml  c:\Test2\FileExtMap.xml /f
      xcopy c:\Test1\proinit.xml c:\Test2\proinit.xml /f
      I no longer get asked about the views folder, but I still get asked about the xml files , whether they are files or directories??
      Will the /i switch work there as well?


      contrex

      • Guest
      Re: xcopy can't tell a file from a directory?
      « Reply #3 on: August 04, 2007, 09:15:09 AM »
      I no longer get asked about the views folder, but I still get asked about the xml files , whether they are files or directories??
      Will the /i switch work there as well?

      I think so. Why don't you try it and see?


      nubia

        Topic Starter


        Rookie

        Re: xcopy can't tell a file from a directory?
        « Reply #4 on: August 04, 2007, 09:24:11 AM »
        Ha! Ha!
        Dumb question I guess.. :-[
        OK I'll try it..
        Thanks again for your help.

        nubia

          Topic Starter


          Rookie

          Re: xcopy can't tell a file from a directory?
          « Reply #5 on: August 04, 2007, 09:36:44 AM »
          Well I tried it and it doesn't work!
          Code: [Select]
          :: Resets Test
          cd ../..
          cd Test2
          rmdir c:\Test2\views /s
          del AppointmentsMap.xml
          del ContactsMap.xml
          del FileExtMap.xml
          del proinit.xml
          xcopy c:\Test1\views  c:\Test2\views /i/e
          xcopy c:\Test1\AppointmentsMap.xml c:\Test2\AppointmentsMap.xml /i
          xcopy c:\Test1\ContactsMap.xml c:\Test2\ContactsMap.xml /i
          xcopy c:\Test1\FileExtMap.xml  c:\Test2\FileExtMap.xml /i
          xcopy c:\Test1\proinit.xml c:\Test2\proinit.xml /i
          I still get asked if the xml files are files or directories??

          contrex

          • Guest
          Re: xcopy can't tell a file from a directory?
          « Reply #6 on: August 04, 2007, 09:53:12 AM »
          Well I tried it and it doesn't work!

          Microsoft's notes about Xcopy include:

          Quote
          Syntax

          xcopy Source [Destination] [/w] [/p] [/c] [/v] [/q] [/f] [/l] [/g] [/d[:mm-dd-yyyy]] [/u] [/i] [/s [/e]] [/t] [/k] [/r] [/h] [{/a|/m}] [/n] [/o] [/x] [/exclude:file1[+[file2]][+[file3]] [{/y|/-y}] [/z]

          Quote
          /i : If Source is a directory or contains wildcards and Destination does not exist, xcopy assumes destination specifies a directory name and creates a new directory. Then, xcopy copies all specified files into the new directory. By default, xcopy prompts you to specify whether Destination is a file or a directory.

          Quote
          Specifying whether Destination is a file or directory

          If Destination does not contain an existing directory and does not end with a backslash (\), the following message appears:

          Does destination specify a file name
          or directory name on the target
          (F = file, D = directory)?

          Press F if you want the file or files to be copied to a file. Press D if you want the file or files to be copied to a directory.

          You can suppress this message by using the /i command-line option, which causes xcopy to assume that the destination is a directory if the source is more than one file or a directory.

          First I suggest you read the above and see if any of it applies to your situation. Second I suggest you go to Microsoft's page about Xcopy and read that

          http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true

          Thirdly I suggest you change your code eg

          Quote
          xcopy c:\Test1\AppointmentsMap.xml c:\Test2\

          and try that.


          nubia

            Topic Starter


            Rookie

            Re: xcopy can't tell a file from a directory?
            « Reply #7 on: August 04, 2007, 10:25:57 AM »
            OK the third suggestion worked..
            Thank you so much for your not giving up on me. :-*

            contrex

            • Guest
            Re: xcopy can't tell a file from a directory?
            « Reply #8 on: August 04, 2007, 11:17:42 AM »
            Nubia, no sweat! Always glad to help.