Batch script to move contents of folder up

December 10, 2010 at 20:05:11
Specs: Windows 7
Hey all,

I am wondering if someone could help me out.

I am in need of a batch script that will look inside a folder and take all the contents of that folder, and move them up to the location of the original folder.


G:\My Videos\Movies\9 [2010]\9 [2010].jpg
G:\My Videos\Movies\9 [2010]\9 [2010].avi

would both be moved to

G:\My Videos\Movies

If this script could also work recursively that would be great. As in, There is the Movies directory, going through all the folders in that directory and moving the files from each folder into the Movies folder.

Thanks all.

See More: Batch script to move contents of folder up

Report •

December 10, 2010 at 21:06:47
I got this working myself.

To anyone that is interested in how I did it, this is the code I used.

@echo off
setLocal EnableDelayedExpansion

pushd "G:\My Videos\Movies"
for /f "tokens=* delims= " %%a in ('dir/b/ad') do (
move "%%a\*.*"

I put that script in the Movies folder and it did the rest. I then organised by file type, selected all the empty folders and deleted them all. You could add to the script to make it do that for you, but I figured it was a little dangerous so I didn't try.

Report •

December 11, 2010 at 01:40:21
I like the way you did that.

Life is too important to be taken seriously.


Report •

Related Solutions

Ask Question