I am trying to figure out a way to batch move files from inside a directory up a single directory.
Not sure if I can put what I want to do in words. See in the example below, I have many directories that are like the "1st" and "3rd" directories below. They each have one directory inside of them with files. I would like to batch move all of the files from the directory inside of them and place them in the directory directly above them. Basically the files in the 2nd directory into the 1st directory, the files in the 4th directory into the 3rd directory, etc...
Example:
Root dir
1st dir
2nd dir (files are in this directory)
3rd dir
4th dir (files are in this directory)
...
Not sure if this is possilbe, but any help would be greatly appreciated. I have been having a hard time using google for this one!
JP
Batch move files up one directory for multiple directories
Moderator: DosItHelp
Re: Batch move files up one directory for multiple directori
Code: Select all
@for /r "C:\TEST\ROOT" %%a in (.) do @(
pushd "%%a"
move * .. >Nul 2>&1
popd
)
-
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
- Contact:
Re: Batch move files up one directory for multiple directori
I can't help you right now, aside from saying that the answer is under for /? where it says "substition of FOR variable references".
Edit: Nvm, amel to the rescue. But you should still learn it.
Edit: Nvm, amel to the rescue. But you should still learn it.
Re: Batch move files up one directory for multiple directori
Amel, thanks this is great and much appreciated!! Orange_batch, I agree I need to learn it !!
I guess I should have mentioned I had subdirectories as well. Does this make it more difficult? I have been experiementing off and on today with this code and not having much luck...
JP
I guess I should have mentioned I had subdirectories as well. Does this make it more difficult? I have been experiementing off and on today with this code and not having much luck...
JP
Re: Batch move files up one directory for multiple directori
.
Try this it will make you an intermediate in notime, you'll then be able to solve most problems yourself.
MS-DOS/MSDOS Batch Files: Batch File Tutorial and Reference
http://www.allenware.com/icsw/icswidx.htm
Try this it will make you an intermediate in notime, you'll then be able to solve most problems yourself.
MS-DOS/MSDOS Batch Files: Batch File Tutorial and Reference
http://www.allenware.com/icsw/icswidx.htm