Mohammad
Mohammad

Reputation: 33

Batch to move files in a folder to another folder?

I want to create a batch file that moves all the files in this directory to its father directory. Like for example if I have a directory " Something " that contains files :

...New Folder/Something

And I want to move the files in " Something " to New folder.

Is there such a command?

Thanks a bunch :)

Upvotes: 1

Views: 2703

Answers (2)

lornova
lornova

Reputation: 6933

It is possible only if you don't have subdirectories, because move doesn't walk the subdirectories. You can use xcopy with /E, however it will not delete the copied files and directories. Then you should use del ., but to delete the subdirectories you should call rd for each one, and that is not possible in batch files.

Upvotes: 0

Saul
Saul

Reputation: 1002

Presuming you're talking about Windows batch files, move *.* ..\ should do the trick.

Edit: For example, if you opened cmd, you could input:

cd C:\New Folder\Something
move *.* ..\

which would move all files in C:\New Folder\Something into its 'father' directory.

Upvotes: 2

Related Questions