Move files to folders with same number in name
May 14, 2016 3:51 PM   Subscribe

I have several hundred files and folders who don't share names, but do share numbers. I'm looking for an automated solution to put the files in the folders that share the same numbers. Windows 7.

For sake of example, let's say I have the following folders/directories:

apple01 (abc)
apple02 (def)
apple03 (ghi)
apple04 (jkl)
apple05 (mno)

and I have the following files in the same root directory as the folders above.


the end result is having redDelicious01.jpeg in apple01 (abc), redDelicious02.jpeg in apple02 (def), and so on.

I feel like there must be a way to automate this other then dragging each file to each folder one by one. Any ideas?
posted by INFJ to Computers & Internet (4 answers total) 3 users marked this as a favorite
I don't think this is perfect, but it may give you a start:
for %a in (01 02 03 04 05) do cmd /c (for /D %b in (apple%a*) do move redDelicious%a.* %b)

posted by forthright at 4:15 PM on May 14, 2016 [1 favorite]

I'm lazy so I use a utility called DropIt for this.
posted by xyzzy at 4:30 PM on May 14, 2016 [1 favorite]

You can search a folder (and all the subfolders) for the "01" files by using the little search box in the file explorer window and typing an asterisk before the 01. If the number is relatively unique or you can further make sure you've just isolated the files you need by sorting by name or date it's not too long a process to find and drag files to the proper folder. If I had hundreds of folders it might be a pain, but if it's more like hundreds of files but only a dozen or less folders this would be very quick.
posted by Nosmot at 5:19 PM on May 14, 2016

You could do this in SSIS with a File System Task, a Foreach Loop Enumerator, and some variables.
posted by oceanjesse at 7:37 PM on May 14, 2016

« Older Is getting your own apartment worth the money?   |   When did Google's reverse image search change, if... Newer »
This thread is closed to new comments.