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

Author Topic: Grabbing the directory name...  (Read 2222 times)

0 Members and 1 Guest are viewing this topic.

Feidom

    Topic Starter


    Rookie

    Grabbing the directory name...
    « on: June 26, 2007, 02:46:49 PM »
    I'm writing a batch file that will copy a certain file into every sub-folder of a particular folder.  Here's what I have, but I'm not sure how to complete it:

    For /f %%a in ( ??? ) do (
         set Folder=%%a
         Copy C:\Files\File.txt C:\Directory\%Folder&\
         )

    I'm not sure what to put in place of "( ???)" that will get the folder name and then drop it into the variable "Folder" for me.  Any help is appreciated.
    Thanks!  :)
    « Last Edit: June 26, 2007, 03:01:36 PM by Feidom »

    DeltaSlaya



      Apprentice
    • Google
      Re: Grabbing the directory name...
      « Reply #1 on: June 26, 2007, 03:23:27 PM »
      In DOS and a batch program I believe
      Code: [Select]
      %cd%Is the environment variable for the current folder?
      System specs:
      Intel Core 2 Duo E6600 (up to 3.3 stock V and air)
      ASUS Striker Extreme
      XFX 8600GT XXX Edition
      2x 1gB Corsair XMS2 DDR2-800
      Seagate Barracuda 320gB SATA
      Raidmax Ninja 918 (520W ATXV2.0 PSU)
      -

      Feidom

        Topic Starter


        Rookie

        Re: Grabbing the directory name...
        « Reply #2 on: June 26, 2007, 03:26:37 PM »
        Figured it out:

        C:
        CD C:\Directory
        For /D %%a in (*) do XCopy C:\Files\File.txt C:\Directory\%%a /y


        Thanks