Copy folder structure and filename only

By yash321 ยท 12 replies
Mar 9, 2010
  1. This Quesiton may be asked serveral times but i m looking for something crazy that's make no sense but that will help me in testing my REGEX programing

    I have a directoy :c:/testing

    in which there are serveral files or subfolder's which contain
    - movie files (.avi , .mpg , wmv)
    - some html file

    I want to copy the folder structure as well as it will also copy the file name of movie file and create textfile with same name of movie

    Like :

    Original Folder :


    i want output like this (Just create a empty textfile)


    Suggest me how to do

    - Any software
    - Any Trick
    - Any Dos prompt prograaming

    I just want to do this

  2. ravisunny2

    ravisunny2 TS Ambassador Posts: 1,986   +12

  3. jobeard

    jobeard TS Ambassador Posts: 11,173   +989

    that tool is a gui (so there's no automation)
    and the .TXT is created in the same dir as the original

    the languages that help here are Perl and PHP
    as a prototype (irrespective of language)
    srcDir = c:\testing
    dstDir = c:\elsewhere
    foreach name ( readDir(.) ) do {
       if $name is dir {
       } else {
          rootName = getRoot($name)  # for a name like [B]foo.avi[/B], capture the FOO
          ext     =  getExt($name)   # and isolate the existing AVI
          touch($dstName\$rootName.txt)   #creating an EMPTY \elsewhere\[B]foo.txt[/B]
          touch($dstName\$name.txt)   #creating EMPTY \elsewhere\[B]foo.avi.txt [/B]     
    this will ONLY work on the contents of $srcDir, ie will not descend into subdirs.
    for that, you need a mod for "recursive descent"
  4. ravisunny2

    ravisunny2 TS Ambassador Posts: 1,986   +12


    Sure Filenote it is a GUI.

    As for the txt file, xcopy can not just create the skeleton dir structure, but copy the txt file to it.

    For automation, one can even use a cmd file, but I personnaly consider that clumsy.

    yash321, is apparently not too well versed in programming, or he would not make this post.

    Why not put in the mod for "recursive descent", so he can use the code to meet his needs ?

    Personally, I'd write a 'c' or java routine, for the automation.

    Peace and goodwill.
  5. jobeard

    jobeard TS Ambassador Posts: 11,173   +989

    I'm working on a PHP implementation ...
  6. jobeard

    jobeard TS Ambassador Posts: 11,173   +989

    ... completing testing and documentation

    meanwhile you need to DL and install PHP for windows

    pick the Bin Install (PHP 5.3) for your architecture and install it at C:\PHP
    you may choose either {Non Thread Safe, or Non Thread Safe}

    I'll post the options necessary for the \PHP\php.ini with the tool
  7. jobeard

    jobeard TS Ambassador Posts: 11,173   +989

    the attachment contains
    description.txt of the invocation
    readme.txt containing
    • public release
    • sample results
    • requirements
    • recommended PHP install location and ini settings
    • and notes on Operational Issues
    the program RDescent.php
    and a DIRNAME for install testing​

    Attached Files:

  8. ravisunny2

    ravisunny2 TS Ambassador Posts: 1,986   +12

    Kudos, jobeard!

    Perhaps, there should be a section for "SmartPacks/Utilities/Tools" developed by members.
  9. SNGX1275

    SNGX1275 TS Forces Special Posts: 10,742   +422

    You guys are making it far too hard. Just do this from a DOS prompt (after navigating to the dir).
    dir /s > listing.txt
  10. LNCPapa

    LNCPapa TS Special Forces Posts: 4,276   +461

    That'll just give you a text file with a directory and file listing from his starting point down. He wants the actual folders to be created elsewhere and empty placeholders for the actual files.
  11. jobeard

    jobeard TS Ambassador Posts: 11,173   +989

    btw: to retain some portion of the original source directory, the last parmature can be

    . (ie the period) to descend all subdirs


    .\subdiname which will descend only that subdir (and everything therein) and
    create a result assuming (-t \index) of \index\subdirname\ and all descendant materials.

    If we assume that the current dir is My Pictures, then you can capture and keep the substructure of your pictures :)
  12. jobeard

    jobeard TS Ambassador Posts: 11,173   +989

    SNGX1275's solution has some merit -- HD space consumption

    the DIR /S solution creates ONE file with a minimum disk usage of one CLUSTER and expands minimally to contain all the names

    The RDescent.php solution creates zero byte-size files which still take ONE CLUSTER EACH. This will waste significant HD space as the number of files created increases.

    The content (eg: 06/20/2005 03:56 PM 394,025 bookmarks.txt) also provides more
    information about the original file, (date, time, size) but performing automation over that list
    could be an issue if all the O.P. needed was the file name (must read & parse).
  13. SNGX1275

    SNGX1275 TS Forces Special Posts: 10,742   +422

    Are you sure? Maybe because I didn't read in detail the replies, I just saw they involved a lot more complexities than a few characters from the DOS prompt. I just focused on this from the original post:
    Ok now after more carefully reading... I can see I wasn't correct.
Topic Status:
Not open for further replies.

Similar Topics

Add your comment to this article

You need to be a member to leave a comment. Join thousands of tech enthusiasts and participate.
TechSpot Account You may also...