Solved DOS Script to flatten directory - urgent

February 26, 2014 at 02:40:26
Specs: Windows 7
I could find many command to flatten the directory using dos, but I am looking for a Dos script with proper logs (for own auditing) to move all files to level 1 folder.

My current directory look like:

Folder 1
-------File1.txt
Folder 2
-------File2.txt
Folder 3
-------File3.txt
--------------Folder31
--------------File31.txt
-------Folder 311
--------------File311.txt
Folder4
File4.txt
Need script to change it to:

Folder 1
-------File1.txt
Folder 2
-------File2.txt
Folder 3
-------File3.txt
-------File31.txt
-------File311.txt
Folder4
-------File4.txt

Many Thanks in advance.


Requirements:

Identify all the Level 1 folders which doesn't have any subfolders in it (in above example that would be Folder 1, Folder 2 & folder 4)
Move all identified folders in above step to a separate directory (I will specify the path in a variable in the script)
Run a script on remaining folders (which has subfolders in it) to remove all level 2 folders onwards from it (preserving level 1 folder) as shown in the example


See More: DOS Script to flatten directory - urgent

Report •


#1
February 26, 2014 at 13:52:29
✔ Best Answer
"Dos script with proper logs (for own auditing..."
As you pointed out, the mechanics is no big deal, but the question is what specifically constitutes a "proper log": A) what information is required, and B) what format to present it. You could just leave echo ON, and pipe the script output to a file, i believe, but it would be kind of hard to read. Or for each directory, you could do this prior to moving files: dir /b /s *.txt >>..\logmove.log

Report •
Related Solutions


Ask Question