Copy folder structure and filename only

Status
Not open for further replies.
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 :

c:\testing\folder1\abc.wmv
c:\testing\folder2\folder2.2\folder2.3\bca.html
c:\testing\folder3\folder3.2\xyz.avi

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

c:\yash\folder1\abc.txt
c:\yash\folder2\folder2.2\folder2.3\bca.txt
c:\yash\folder3\folder3.2\xyz.txt


Suggest me how to do

- Any software
- Any Trick
- Any Dos prompt prograaming

I just want to do this

Thnx
 
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)
Code:
srcDir = c:\testing
dstDir = c:\elsewhere
changeDir($srcDir)
foreach name ( readDir(.) ) do {
   if $name is dir {
      mkDir($dstDir\$name)
   } 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"
 
Neat.

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.
 
... 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
 
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​
 

Attachments

  • Traversal.zip
    6.3 KB · Views: 11
Kudos, jobeard!

Perhaps, there should be a section for "SmartPacks/Utilities/Tools" developed by members.
 
You guys are making it far too hard. Just do this from a DOS prompt (after navigating to the dir).
Code:
dir /s > listing.txt
 
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.
 
btw: to retain some portion of the original source directory, the last parmature can be

. (ie the period) to descend all subdirs

or

.\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 :)
 
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).
 
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.
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:
Original Folder :

c:\testing\folder1\abc.wmv
c:\testing\folder2\folder2.2\folder2.3\bca.html
c:\testing\folder3\folder3.2\xyz.avi

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

c:\yash\folder1\abc.txt
c:\yash\folder2\folder2.2\folder2.3\bca.txt
c:\yash\folder3\folder3.2\xyz.txt

Ok now after more carefully reading... I can see I wasn't correct.
 
Status
Not open for further replies.
Back