avery_larry
This will be the reverse of what most people will first think in relation to empty directories.
I don't want to delete them.
I want to find them so I can create them in another location.
My backup procedure (I'll explain that partially below) seems to work very well, but it skips empty folders. Any ideas for a fast way to find empty folders? This would run across a WAN link traversing several hundred gigabytes of data -- thousands of folders, millions of files.
My backup:
First, I use:
xcopy /e /t and mklink /h
to create a hardlinked copy of the backup location (not the live data) for a backup history (or version history or snapshot). Then I use robocopy to create a list of new, modified, and deleted files/folders. I do not actually use robocopy to do the file transfers. Once I have the list of new/modified/deleted files/folders, I use that list to delete the modified/deleted files/folders from the backup location (which actually just deletes the hard link); create any new folders; and then copy the new/modified files from the live data location to the backup location.
As far as I could find, robocopy either lists all folders, whether new, old, or modified, if you don't use the /ndl switch. If you use the /ndl list, then it doesn't record any new folders at all (though it does list deleted folders).
As I'm writing this, it occurs to me that I could probably just let robocopy list all the directories and then simply attempt to md all the directories. Seems inefficient.
----------------------------
#2 11 Jan 2011 15:45
RG
https://www.commandline.co.uk/lib/treeview/index.php
Batch Function Library
File And Directory Functions
IsDirEmpty
Windows Shell Scripting and InstallShield
----------------------------
#3 11 Jan 2011 16:50
avery_larry
Interesting, but probably inefficient. A modified version:
call it with the directory to check. Errorlevel 1 means it is empty.
Code: Select all
for /f %%a in ('dir /a /b "%1"') do goto :eof
exit /b 1
Never knew about
dir /a
I always wondered why there wasn't a way to list all files instead of having to separately list hidden and system files.
Last edited by avery_larry (11 Jan 2011 16:52)