recreating folder structure

Soldato
Joined
19 Jul 2005
Posts
7,069
Location
S. Yorkshire
I have a set of files that came from a folder structure but have been changed and dumped into one single folder.
Are there any ways to recreate the original structure without manually copying and pasting?
In this example there are no duplicate filenames. I have the original folder structure as reference.

I'm hoping there is something that can look at the filename and reference the same filename in the original folder and either place it back in the original folder or create a parallel structure.

Does such a thing exist without getting into the scary world of PERL or Python?:D
 
This seems a bit too specialised for there to be a piece of software out there to do it unfortunately. However it might be reasonably simple depending on how much information you already have.

Do you have the old folder structure including which files were in which folder?

Are all the files in the single folder or is it just a subset of the original list?

In theory if you have all the files and a full listing of what should be where it should be possible to tie both together and spit out a list of move and mkdir commands. It will mean some programming of some kind though.
 
I know, I'm asking a lot here.
I have the original structure with all the original files in. I then have all the changed files in a single folder outside of that original structure.

If it were a vast number of files I'd probably export the contents of the folder structure into a text file and import that into excel. I'd then use Concatenate to create a batch file to move or copy the files into a matching structure.
The problem with this is that it requires a lot of set up each time, and these tasks seem to happen too often to do this if there is any alternative!
 
Needs fleshing out but a fairly simple bat file should do it, something along the lines of...

Code:
set startpath=c:\folder
set endpath=d:\folder

xcopy %startpath% %endpath% /T /E

for /f %%A IN ('dir %startpath%\*.* /s') DO (
   copy "%endpath%\%%~nA" "%endpath%\%%~pA"
)


that code's never gonna work but something along those lines. Basically it is...

startpath, is your sorted structure
endpath, is your folder with all the files in one.
use xcopy to recreate the folder structure.
do a dir of all files in your sorted folder.
%%~nA, should just give you the file name and..
%%~pA, should give you the path.

can't remember if it will let you do %%~nA though, you may need to set a var to =%%A first and then turn on delayed var expansion as it is within a loop.

this does also assume that all the files are in both locations, any differences should just throw up errors though. it also seems a bit easier doing it this way around as opposed to looking at a file name in endpath and then looking it up in startpath.

if i get time i'll see if i can test and come up with a working one but can't at the mo.
 
That looks really promising, thank you.
I'm not in urgent need of this, but it's something that would be worthwhile for me again and again.

Cheers
 
Back
Top Bottom