I found several such questions and tried to adapt the answers to my needs but no luck so far. I'm trying to create two context menu entries in Windows 7 that would:
- Move all files from subfolders in a given folder to the parent folder. Duplicates should be renamed to
Filename-Duplicate
but not deleted. - Delete all empty subfolders.
I was able to successfully create the needed entries in:
HKEY_CLASSES_ROOT\Directory\shell\Delete Empty Subfolders\command
and
HKEY_CLASSES_ROOT\Directory\shell\Move all subfiles here\command
The commands (and I think here lies the problem) are as follows for the two:
for /r ROOT %%d in (*.*) do move "%%d" "%1\"
for /f "delims=" %%d in ('dir /s /b /ad ^| sort /r') do rd "%%d"
When I select a folder that I created for testing this and select either one from the context menu it seems the batch file on disk where the Registry entry points to is found and executed but with no result.
I think the problem is the commands themselves. I'm not very experienced with FOR either. If this can be accomplished with PowerShell I'm open to that option. If at all possible I would avoid using external dependencies such as 3rd party apps to execute the commands.