Batch file for moving files to folder?

Etihtsarom

New member
Power User
Local time
6:52 PM
Messages
246
Hello,
Wanted to see if any one here wouldn't mind writing a batch file or script that would move multiple files to a target folder. Here are the specifics:
HDD1 Contains Folders A,B,C,etc...
Folder A contains Folder A1 which contains File A2
Folder B contains Folder B1 which contains File B2
Folder C contains Folder C1 which contains File C2
Folder D contains Folder D1 which contains File D2
Folder E contains Folder E1 which contains File E2
Folder F contains Folder F1 which contains File F2

And what I need to do is move A2,B2,...F2.. to the drive root.

This would really save some time over moving these files manually, because they're numerous.
Or if you know of any utilities that can do this, please let me know
Thanks.
 

My Computer

Computer Manufacturer/Model Number
SevenForums
OS
7 Prof
CPU
Q9550
Motherboard
Maximus II Formula
Memory
2x2 Mushkin Ascent 8500
Graphics Card(s)
4870X2
Sound Card
X-Fi Xtreme Gamer
Monitor(s) Displays
LN32A550
Screen Resolution
1920x1080
Hard Drives
Intel G2 80GB
5x1TB
PSU
Corsair 1000
Case
Cosmos
Cooling
Yates^13
Keyboard
G15v1
Mouse
MX518
Internet Speed
6Mbps
I am assuming that these all folders are in X drive

such that your file A2.xxx is in X:\Folder A\Folder A1

move "X:\Folder A\Folder A1\File A2.xxx" X:\
move "X:\Folder B\Folder B1\File B2.xxx" X:\
move "X:\Folder C\Folder C1\File C2.xxx" X:\
move "X:\Folder D\Folder D1\File D2.xxx" X:\
move "X:\Folder E\Folder E1\File E2.xxx" X:\
move "X:\Folder F\Folder F1\File F2.xxx" X:\

save it as bat file.
If you are using windows 7 than open the file in Administrator mode.

I hope it will help
 

My Computer

OS
Windows 7
CPU
Intel Quad Core
Motherboard
Intel DG41RQ
Memory
2GB
Graphics Card(s)
Inbuilt
Sound Card
Inbuilt
Monitor(s) Displays
1
Hard Drives
500GB
Case
Zebronics
Another alternative to do it:

for %s in (A B C D E F) do move "x:\Folder %s\Folder %s1\File %s2.xxx" x:\

That's assuming you type it at the command line. If you put it in a .BAT file, make every % in the line above %%.
 

My Computer

Computer Manufacturer/Model Number
Custom Built
OS
Win 7 RC, Win XP, Win 2003, Ubuntu
CPU
Core i7 920
Motherboard
ASUS P6T Deluxe V2
Memory
12 GB Corsair XMS DDR3 1600
Graphics Card(s)
NVidia GTX 285 OC
Sound Card
Mobo integrated
Monitor(s) Displays
Asus 24" LED LCD
Screen Resolution
1920x1080
Hard Drives
Plextor PX-128M2S 128GB SSD
PSU
Enermax Galaxy EVO 1250W
Case
Thermaltake Shark
Cooling
Thermalright Ultra 120 True Black
Keyboard
Black USB Unicomp (modern IBM Model M)
Mouse
Logitech 3 button optical (cheap but comfortable!)
Internet Speed
Comcast Business account, 50/15
Other Info
Custom built server feeds this rig; 14 TB in RAID6 (16 WD1TB on Areca ARC-1160ML2)
Thanks for the suggestions. The problem here is that A B C D ... are really long folder names and there are tons of those folders. It simply isn't practical to have to list the actual folder names. I'm looking for something that just dumps all the elements of all folders out to root.
 

My Computer

Computer Manufacturer/Model Number
SevenForums
OS
7 Prof
CPU
Q9550
Motherboard
Maximus II Formula
Memory
2x2 Mushkin Ascent 8500
Graphics Card(s)
4870X2
Sound Card
X-Fi Xtreme Gamer
Monitor(s) Displays
LN32A550
Screen Resolution
1920x1080
Hard Drives
Intel G2 80GB
5x1TB
PSU
Corsair 1000
Case
Cosmos
Cooling
Yates^13
Keyboard
G15v1
Mouse
MX518
Internet Speed
6Mbps
First off it is never and I mean never good to copy files to the root of any drive. Especially C: (if that is your OS drive). It would be much better to move them to X:\MovedFiles or something like that.

Is there some sort of pattern to the folders off the root? Or are you moving everything from all folders off the root? If this is on your C: Drive the script would move everything from the C: drive including Windows (that is if the OS did not protect itself) but it would do a lot of damage. If all the folders are on another drive that would be best, but again if there is no pattern it will be hard to move files without moving files you don't mean to.

Let me know.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell OP7010
OS
Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
Memory
16GB
Monitor(s) Displays
4 Dell 24" LCD
Screen Resolution
1280x1024
Keyboard
Dell
Mouse
Dell Optical
Internet Speed
40meg
If there isn't a pattern, how about non-move folders? There can't be all that many of those. You could do a dir c:\ /ad/b >folderlist.txt at the command line then open folderlist.txt in notepad and search for the folders you don't want moved and remove those lines. Save the file then you can do a for /f and use the .txt as the input source for the folder list to move.
 

My Computer

Computer Manufacturer/Model Number
Custom Built
OS
Win 7 RC, Win XP, Win 2003, Ubuntu
CPU
Core i7 920
Motherboard
ASUS P6T Deluxe V2
Memory
12 GB Corsair XMS DDR3 1600
Graphics Card(s)
NVidia GTX 285 OC
Sound Card
Mobo integrated
Monitor(s) Displays
Asus 24" LED LCD
Screen Resolution
1920x1080
Hard Drives
Plextor PX-128M2S 128GB SSD
PSU
Enermax Galaxy EVO 1250W
Case
Thermaltake Shark
Cooling
Thermalright Ultra 120 True Black
Keyboard
Black USB Unicomp (modern IBM Model M)
Mouse
Logitech 3 button optical (cheap but comfortable!)
Internet Speed
Comcast Business account, 50/15
Other Info
Custom built server feeds this rig; 14 TB in RAID6 (16 WD1TB on Areca ARC-1160ML2)
PS, what is the file extension of the files you want dumped in root? If it's something odd that will only exist in those special folders an easy solution would be:

for /f "tokens=*" %s in ('dir x:\*.weirdextn /s/b') do move "%s" x:\

I also agree with WindowsStar though.. it's usually not prudent to just dump all that stuff to root.
 

My Computer

Computer Manufacturer/Model Number
Custom Built
OS
Win 7 RC, Win XP, Win 2003, Ubuntu
CPU
Core i7 920
Motherboard
ASUS P6T Deluxe V2
Memory
12 GB Corsair XMS DDR3 1600
Graphics Card(s)
NVidia GTX 285 OC
Sound Card
Mobo integrated
Monitor(s) Displays
Asus 24" LED LCD
Screen Resolution
1920x1080
Hard Drives
Plextor PX-128M2S 128GB SSD
PSU
Enermax Galaxy EVO 1250W
Case
Thermaltake Shark
Cooling
Thermalright Ultra 120 True Black
Keyboard
Black USB Unicomp (modern IBM Model M)
Mouse
Logitech 3 button optical (cheap but comfortable!)
Internet Speed
Comcast Business account, 50/15
Other Info
Custom built server feeds this rig; 14 TB in RAID6 (16 WD1TB on Areca ARC-1160ML2)
I used n2ncopy in the past and it works very good.
 

My Computer

Computer Manufacturer/Model Number
Dell 8300
OS
Windows7 Ultimate 64 bit
CPU
I7-2600
Motherboard
Dell
Memory
8GB
Graphics Card(s)
XFX 6870
Sound Card
Onboard
Monitor(s) Displays
Dell ST2410
Screen Resolution
1920x1080
Hard Drives
Seagate 1TB
PSU
Corsair 650TX
Case
Dell 8300
Cooling
Stock
Keyboard
G15
Mouse
G500
Internet Speed
6000/768
PS, what is the file extension of the files you want dumped in root? If it's something odd that will only exist in those special folders an easy solution would be:

for /f "tokens=*" %s in ('dir x:\*.weirdextn /s/b') do move "%s" x:\

I also agree with WindowsStar though.. it's usually not prudent to just dump all that stuff to root.
This might work. I'll give it a try later on. There are altogether about 15 types of files accross all folders, so a much simpler solution would be a search for file types in the drive (not C drive btw) and just move them, albeit 15 times.
 

My Computer

Computer Manufacturer/Model Number
SevenForums
OS
7 Prof
CPU
Q9550
Motherboard
Maximus II Formula
Memory
2x2 Mushkin Ascent 8500
Graphics Card(s)
4870X2
Sound Card
X-Fi Xtreme Gamer
Monitor(s) Displays
LN32A550
Screen Resolution
1920x1080
Hard Drives
Intel G2 80GB
5x1TB
PSU
Corsair 1000
Case
Cosmos
Cooling
Yates^13
Keyboard
G15v1
Mouse
MX518
Internet Speed
6Mbps
Cool. Another alternative to automate it to cover your varied filetypes:

for %s in (ext1 ext2 ext3 ext4) do for /f %t in ('dir x:\*.%s /s/b') do move "%t" x:\

That way you only have to type in the exts once and it does the relocations automatically.
 

My Computer

Computer Manufacturer/Model Number
Custom Built
OS
Win 7 RC, Win XP, Win 2003, Ubuntu
CPU
Core i7 920
Motherboard
ASUS P6T Deluxe V2
Memory
12 GB Corsair XMS DDR3 1600
Graphics Card(s)
NVidia GTX 285 OC
Sound Card
Mobo integrated
Monitor(s) Displays
Asus 24" LED LCD
Screen Resolution
1920x1080
Hard Drives
Plextor PX-128M2S 128GB SSD
PSU
Enermax Galaxy EVO 1250W
Case
Thermaltake Shark
Cooling
Thermalright Ultra 120 True Black
Keyboard
Black USB Unicomp (modern IBM Model M)
Mouse
Logitech 3 button optical (cheap but comfortable!)
Internet Speed
Comcast Business account, 50/15
Other Info
Custom built server feeds this rig; 14 TB in RAID6 (16 WD1TB on Areca ARC-1160ML2)
Thanks.
Your script works. I also found something else that works pretty well for others if they don't wanna mess with batch files.
Suction: It dumps all files out to parent folders. Suction | The Dr's Office
 

My Computer

Computer Manufacturer/Model Number
SevenForums
OS
7 Prof
CPU
Q9550
Motherboard
Maximus II Formula
Memory
2x2 Mushkin Ascent 8500
Graphics Card(s)
4870X2
Sound Card
X-Fi Xtreme Gamer
Monitor(s) Displays
LN32A550
Screen Resolution
1920x1080
Hard Drives
Intel G2 80GB
5x1TB
PSU
Corsair 1000
Case
Cosmos
Cooling
Yates^13
Keyboard
G15v1
Mouse
MX518
Internet Speed
6Mbps
Back
Top