I need to move thousands of files from one folder to new folders

RHODESSURVEYING

New member
Local time
2:27 PM
Messages
3
I need to figure out a way to take thousands of .dwg,.docx,.xlsx, ect. files and organize them all into folders. I want to take file named 54321.xlsx and 54321.docx and put them in the folder 54321. Right now all my .docx files are in a folder, but I want them all seperated by seperate folders. I have already made the 100k folders for each job using a batch file. Now I just need to figure out how to organize the files into the corresponding folders. Please Help! :confused:
 

My Computer My Computer

At a glance

XP 64 AND WINDOWS 7 32BIT
OS
XP 64 AND WINDOWS 7 32BIT
I need to figure out a way to take thousands of .dwg,.docx,.xlsx, ect. files and organize them all into folders. I want to take file named 54321.xlsx and 54321.docx and put them in the folder 54321. Right now all my .docx files are in a folder, but I want them all seperated by seperate folders. I have already made the 100k folders for each job using a batch file. Now I just need to figure out how to organize the files into the corresponding folders. Please Help! :confused:

One caveat. That many nested folders will slow the computer to a crawl unless you have really good hardware (RAM (8gigs), CPU,. i7, etc).
 

My Computer My Computer

At a glance

Win 8 Release candidate 8400[email protected]4 gigsNvidia 9600M
Computer Manufacturer/Model Number
HP Pavillion dv-7 1005 Tx
OS
Win 8 Release candidate 8400
CPU
[email protected]
Memory
4 gigs
Graphics Card(s)
Nvidia 9600M
Sound Card
HD built-in
Monitor(s) Displays
17" Wxga
Screen Resolution
1440x900
Cooling
none
Internet Speed
45Mb down 5Mb up
file organizing

Thank you,
Yes I realized that already. I created subfolders to help. 80,000 files are under a file called archive. We will not need to access this much. 8,000 are in a different sub folder and we only have 2,000 folders in the main file. I just need to figure out how to get our files in the correct folders.
 

My Computer My Computer

At a glance

XP 64 AND WINDOWS 7 32BIT
OS
XP 64 AND WINDOWS 7 32BIT
Well this is really a job for a 20-30 line script. Python, perl whatever...

Don't know what your skill level with that sort of thing is, but even as a coding noob it may take less time to figure out how to write a python script than to do it all by hand. (And pick up an awesome skill for future problems like this at the same time)

(An experienced scripter could probably do it in 5 minutes if here is anyone like that in the company)
 

My Computer My Computer

At a glance

Windows 7 x64 Ultimatei7 96012 Gig Corsair DominatorNvidia 480
Computer Manufacturer/Model Number
Scratch built
OS
Windows 7 x64 Ultimate
CPU
i7 960
Motherboard
Asus P6X58D
Memory
12 Gig Corsair Dominator
Graphics Card(s)
Nvidia 480
Sound Card
Maudio Delta 44 + breakout box
Monitor(s) Displays
Dell UltraSharp U2410 24in and Samsung 21 dual monitors
Screen Resolution
1920x1200 and 1280x1024
Hard Drives
Primary: Intel X-25M G2 160G SSD
Secondary: Segate baracuda 1.0 TB
HDs in AHCI mode.
PSU
Corasair TX850
Case
Cooler Master HAF
Cooling
Corsair H50
Keyboard
Logitech G15 + N52 game pad
Mouse
Logitech MX518
Internet Speed
15kbs down 4.5kbps up
Other Info
WEI 7.6
CPU & RAM 7.6
Graphics 7.9
Hard disk 7.7
wow thanks

I appreciate the info. I guess I am going to be trying to learn python script this weekend. Any direction to send me on the net to find how to do this?
 

My Computer My Computer

At a glance

XP 64 AND WINDOWS 7 32BIT
OS
XP 64 AND WINDOWS 7 32BIT
Well you can google for "Python Scripting" and install the interpreter (from here http://www.python.org/) and it comes with a simple editor. Then try googling "Getting started with python". I don't have any specific site recomendations. There will be tons of sample code if you can find one that seems close to what you want to do. Like "Sort files using pyton".

For example, this sample does several of the things you will need to do for your task even though it doesn't do exactly the same thing:

Using Python to delete old files and keep newest ones : Graham Lyons

But it shows how to iterate over all files in a foilder, find information about them and then do something with them... ANd it's only 7 lines of code. Yours may be a bit longer but should still be pretty simple.
 

My Computer My Computer

At a glance

Windows 7 x64 Ultimatei7 96012 Gig Corsair DominatorNvidia 480
Computer Manufacturer/Model Number
Scratch built
OS
Windows 7 x64 Ultimate
CPU
i7 960
Motherboard
Asus P6X58D
Memory
12 Gig Corsair Dominator
Graphics Card(s)
Nvidia 480
Sound Card
Maudio Delta 44 + breakout box
Monitor(s) Displays
Dell UltraSharp U2410 24in and Samsung 21 dual monitors
Screen Resolution
1920x1200 and 1280x1024
Hard Drives
Primary: Intel X-25M G2 160G SSD
Secondary: Segate baracuda 1.0 TB
HDs in AHCI mode.
PSU
Corasair TX850
Case
Cooler Master HAF
Cooling
Corsair H50
Keyboard
Logitech G15 + N52 game pad
Mouse
Logitech MX518
Internet Speed
15kbs down 4.5kbps up
Other Info
WEI 7.6
CPU & RAM 7.6
Graphics 7.9
Hard disk 7.7
Are you planning to only access these via program or command line? I'm just thinking Explorer or any Gui file manager may choke when sifting through all the file and folder attributes.

Also wide may be better than deep if you plan on using Explorer. It balks if the length of the nested folder paths start approaching 260 characters.
 

My Computer My Computer

At a glance

Windows 7 32 bitAMD 5200+ dual core2 GBNVidia GeForce 6150SE 128 MB
Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
You know, if you're a windows nut... and you like scripts... you should be hanging out here:
Hey, Scripting Guy! How Can I Move Files Based on a Portion of the File Name? - Hey, Scripting Guy! Blog - Site Home - TechNet Blogs
That one sounds similar, but you can edit or search the site if thats not what you're looking for.
Make sure it will work on your system first. http://technet.microsoft.com/en-us/scriptcenter/dd940113
I've only tried this on XP so I'm not sure what may have changed with 7.
 
Last edited:

My Computer My Computer

At a glance

Windows 7 Home Premium 64 OEM
Computer Manufacturer/Model Number
Acer Ferrari One/HP Proliant Microserver/Random Monstrosities
OS
Windows 7 Home Premium 64 OEM
I have an AutoIt3 function that returns the "base name" of a path. For example, _FileBaseName("C:\MyFolder\MyFile.txt") returns "MyFile"

You could use it to put the file into the proper folder

Whatever programming language you decide to use should either have a canned function that does the same, or have library functions you can use to roll your own without too much difficulty

Basically it just returns the characters after the last backslash up to but not including the first extension dot

Code:
; return the basename part of a file path
; works only for files with extension
; e.g. returns "test" for c:\folder\test.exe path
;
Func _FileBaseName($path)
	If $path = "" Then Return ""
	If StringLen($path) < 3 Then Return ""

	Local $pos = StringInStr($path, "\", 0, -1)
	$pos += 1
	Local $tmp = StringMid($path, $pos)
	Return StringLeft($tmp, StringInStr($tmp, ".", 0, -1) - 1)
EndFunc   ;==>_FileBaseName

So in AutoIt3 you would do something like
$basename = _FileBaseName($path)

FileMove($basename & ".*", $basename & "\*.*)

The "&" is string concatenation operator. So it becomes "move files with base name x inside folder named x"

Should be pretty simple if the folders are all on the same level.
 

My Computer My Computer

At a glance

Windows 7 32 bitAMD 5200+ dual core2 GBNVidia GeForce 6150SE 128 MB
Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
Back
Top