Solved

vba for file FOLDER question

Posted on 2013-02-05
8
202 Views
Last Modified: 2013-02-05
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
0
Comment
Question by:fordraiders
  • 4
  • 4
8 Comments
 
LVL 26

Accepted Solution

by:
redmondb earned 500 total points
ID: 38856071
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
 
LVL 3

Author Comment

by:fordraiders
ID: 38856213
batchfile...Thats different ...ok Thanks
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38856229
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
 
LVL 3

Author Comment

by:fordraiders
ID: 38857400
ok i'm on windows 7 32bit ...been awhile since i ran a batch file
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 26

Expert Comment

by:redmondb
ID: 38857435
While I wouldn't recommend anyone to spend time learning it now, it's hugely useful for one-off's like this.
0
 
LVL 3

Author Comment

by:fordraiders
ID: 38857503
nm i got it to work...Worked perfect !
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 38857507
beautiful and simple to implement.
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38857619
Now that's a compliment - many thanks, fordraiders!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now