| Windows 7: Batch file for moving files to folder? |
04 Jan 2010
|
#1 | | |
Batch file for moving files to folder? 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 System Specs |
| System Manufacturer/Model Number SevenForums OS 7 Prof CPU Q9550 Motherboard Maximus II Formula Memory 2x2 Mushkin Ascent 8500 Graphics Card 4870X2 Sound Card X-Fi Xtreme Gamer Monitor(s) Displays LN32A550 Screen Resolution 1920x1080 Keyboard G15v1 Mouse MX518 PSU Corsair 1000 Case Cosmos Cooling Yates^13 Hard Drives Intel G2 80GB
5x1TB Internet Speed 6Mbps |
04 Jan 2010
|
#2 | | |
I am assuming that these all folders are in X drive
such that your file A2.xxx is in X:\Folder A\Folder A1 Quote: 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 System Specs | | OS Windows 7 CPU Intel Quad Core Motherboard Intel DG41RQ Memory 2GB Graphics Card Inbuilt Sound Card Inbuilt Monitor(s) Displays 1 Case Zebronics Hard Drives 500GB |
04 Jan 2010
|
#3 | | Win 7 RC, Win XP, Win 2003, Ubuntu Pennsylvania |
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 System Specs | | System 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 NVidia GTX 285 OC Sound Card Mobo integrated Monitor(s) Displays Asus 24" LED LCD Screen Resolution 1920x1080 Keyboard Black USB Unicomp (modern IBM Model M) Mouse Logitech 3 button optical (cheap but comfortable!) PSU Enermax Galaxy EVO 1250W Case Thermaltake Shark Cooling Thermalright Ultra 120 True Black Hard Drives Plextor PX-128M2S 128GB SSD 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) |
05 Jan 2010
|
#4 | | |
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 System Specs | | System Manufacturer/Model Number SevenForums OS 7 Prof CPU Q9550 Motherboard Maximus II Formula Memory 2x2 Mushkin Ascent 8500 Graphics Card 4870X2 Sound Card X-Fi Xtreme Gamer Monitor(s) Displays LN32A550 Screen Resolution 1920x1080 Keyboard G15v1 Mouse MX518 PSU Corsair 1000 Case Cosmos Cooling Yates^13 Hard Drives Intel G2 80GB
5x1TB Internet Speed 6Mbps |
05 Jan 2010
|
#5 | | Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64) Earth - I wish I was on Risa |
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 System Specs | | System Manufacturer/Model Number Dell OP760 OS Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64) Memory 8GB Monitor(s) Displays 2 Dell 19" LCD Screen Resolution 1280x1024 Keyboard Dell Mouse Dell Optical Internet Speed 40meg |
05 Jan 2010
|
#6 | | Win 7 RC, Win XP, Win 2003, Ubuntu Pennsylvania |
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 System Specs | | System 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 NVidia GTX 285 OC Sound Card Mobo integrated Monitor(s) Displays Asus 24" LED LCD Screen Resolution 1920x1080 Keyboard Black USB Unicomp (modern IBM Model M) Mouse Logitech 3 button optical (cheap but comfortable!) PSU Enermax Galaxy EVO 1250W Case Thermaltake Shark Cooling Thermalright Ultra 120 True Black Hard Drives Plextor PX-128M2S 128GB SSD 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) |
05 Jan 2010
|
#7 | | Win 7 RC, Win XP, Win 2003, Ubuntu Pennsylvania |
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 System Specs | | System 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 NVidia GTX 285 OC Sound Card Mobo integrated Monitor(s) Displays Asus 24" LED LCD Screen Resolution 1920x1080 Keyboard Black USB Unicomp (modern IBM Model M) Mouse Logitech 3 button optical (cheap but comfortable!) PSU Enermax Galaxy EVO 1250W Case Thermaltake Shark Cooling Thermalright Ultra 120 True Black Hard Drives Plextor PX-128M2S 128GB SSD 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) |
05 Jan 2010
|
#8 | | Windows7 Ultimate 64 bit Charleston |
I used n2ncopy in the past and it works very good. | My System Specs | | System Manufacturer/Model Number Dell 8300 OS Windows7 Ultimate 64 bit CPU I7-2600 Motherboard Dell Memory 8GB Graphics Card XFX 6870 Sound Card Onboard Monitor(s) Displays Dell ST2410 Screen Resolution 1920x1080 Keyboard G15 Mouse G500 PSU Corsair 650TX Case Dell 8300 Cooling Stock Hard Drives Seagate 1TB Internet Speed 6000/768 |
05 Jan 2010
|
#9 | | |

Quote: Originally Posted by Strahan 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 System Specs | | System Manufacturer/Model Number SevenForums OS 7 Prof CPU Q9550 Motherboard Maximus II Formula Memory 2x2 Mushkin Ascent 8500 Graphics Card 4870X2 Sound Card X-Fi Xtreme Gamer Monitor(s) Displays LN32A550 Screen Resolution 1920x1080 Keyboard G15v1 Mouse MX518 PSU Corsair 1000 Case Cosmos Cooling Yates^13 Hard Drives Intel G2 80GB
5x1TB Internet Speed 6Mbps |
06 Jan 2010
|
#10 | | Win 7 RC, Win XP, Win 2003, Ubuntu Pennsylvania |
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 System Specs | | System 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 NVidia GTX 285 OC Sound Card Mobo integrated Monitor(s) Displays Asus 24" LED LCD Screen Resolution 1920x1080 Keyboard Black USB Unicomp (modern IBM Model M) Mouse Logitech 3 button optical (cheap but comfortable!) PSU Enermax Galaxy EVO 1250W Case Thermaltake Shark Cooling Thermalright Ultra 120 True Black Hard Drives Plextor PX-128M2S 128GB SSD 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) Batch file for moving files to folder? problems? All times are GMT -5. The time now is 11:06 PM. | |