vba for file FOLDER question

vba excel 2010
Sorry I could not find a topic area for VBA.
These jpg's are for a excel project to view pics.


I have a folder:

C:\ITEM_JPG\

In this folder i have approx 989,000 jpg files...


They appear as:
1aa002.jpg
2eee44.jpg
10aa345.jpg
21aa355.jpg
41aa212.jpg
etc...


What I need:

I need to create a folder for jpg's that starts with "1" then nsme it "1_startswith"
then do the same up to "9"


Then cut and paste those files go under the appropriate the folders.

example:
anything that startwith "5"  will go under the
"5_startswith" folder.

anything that startwith "4"  will go under the
"4_startswith" folder.



Thanks
fordraiders
LVL 3
FordraidersAsked:
Who is Participating?
 
redmondbConnect With a Mentor Commented:
Hi, fordraiders.

(1) Save the attached file into the folder containing the files.
(2) Rename the file as Startswith.bat. (EE won't load batch files, so I made it a text.)
(3) Run it.

The batch file contains...
for %%a in (1 2 3 4 5 6 7 8 9 0) do md   "%%a_startswith"
for %%a in (1 2 3 4 5 6 7 8 9 0) do move "%%a*jpg" "%%a_startswith"

Open in new window

Regards,
Brian.Startswith.txt
0
 
FordraidersAuthor Commented:
batchfile...Thats different ...ok Thanks
0
 
redmondbCommented:
fordraiders,

With a million files involved there's a lot to be said for a solution that's efficient, effective and economical!

Regards,
Brian.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
FordraidersAuthor Commented:
ok i'm on windows 7 32bit ...been awhile since i ran a batch file
0
 
redmondbCommented:
While I wouldn't recommend anyone to spend time learning it now, it's hugely useful for one-off's like this.
0
 
FordraidersAuthor Commented:
nm i got it to work...Worked perfect !
0
 
FordraidersAuthor Commented:
beautiful and simple to implement.
0
 
redmondbCommented:
Now that's a compliment - many thanks, fordraiders!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.