Solved

vba for file FOLDER question

Posted on 2013-02-05
8
211 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

910 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

23 Experts available now in Live!

Get 1:1 Help Now