Use DOS batch to move all files up 1 directory

Posted by Harminoff on Super User See other posts from Super User or by Harminoff
Published on 2014-08-17T18:56:39Z Indexed on 2014/08/18 16:31 UTC
Read the original article Hit count: 241

I have created a batch file to be executed through the right-click menu in Win7. When I right-click on a folder, I would like the batch file to move all files (excluding folders) up 1 directory. I have this so far:

PUSHHD %1
MOVE "%1\*.*"  ..\

This seems to work as long as the folder I'm moving files from doesn't have any spaces. When the folder does have spaces, I get an error message: "The syntax of the command is incorrect."

So my batch works on a folder titled PULLTEST but not on a folder titled PULL TEST.

Again, I don't need it to move folders, just files. And I would like it to work in any directory on any drive. There will be no specific directories that I will be working in. It will be random.


Below is the registry file I made if needed for reference.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\PullFiles]
@="PullFilesUP"

[HKEY_CLASSES_ROOT\Directory\shell\PullFiles\command]
@="\"C:\\Program Files\\MyBatchs\\PullFiles.bat\" \"%1\""

© Super User or respective owner

Related posts about windows-7

Related posts about command-line