[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

I need a script to automate file moving according to its names rules (II)

Posted on 2006-04-17
5
Medium Priority
?
208 Views
Last Modified: 2010-05-03
I need a vbs script to make the following - inside a directory I have many files which have a similar name (only the 2 last characters are different - for example aaaa10, aaaa11, aaaa12, aaaa13; bbbb10, bbbb12, bbbb13, bbbb14). I need an automatic way to move that group of files that only have the 2 last characters different to a sub-directory with the name corresponding to common characters (for example, for aaaa10, aaaa12, aaaa13, aaaa14 it will create a sub-directory named aaaa, and aaaa10, aaaa12, aaaa13, aaaa14 will be moved inside aaaa). Can you understand what I want ? I do not know to program :( My operating system is Windows XP. If you look at http://www.experts-exchange.com/Programming/Q_21812622.html you can see I have posted a similar question but the difference was only the last character... Just modify that vbs script... I wish I know to program !... Now I have no free time but in future I will learn VB ! Thanks.
0
Comment
Question by:asgarcymed
  • 3
5 Comments
 

Author Comment

by:asgarcymed
ID: 16468906
*) It is always two characters that are different at the end of the filenames;
*) The common part of the names is variable (not always 4 as I used in the example);
*) All the files are in the same folder at the same level (no recurse into subfolders needed);
*) I want the new sub directory in the same folder as the file.
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 1400 total points
ID: 16469077
Change this line:

    baseName = Left(file.Name, Len(file.Name) - 5)

to:

    baseName = Left(file.Name, Len(file.Name) - 6)
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16469138
Lol...

Study the code asgarcymed.  Now is a great time to start learning!

You can find documentation on the language here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/ddfa5183-d458-41bc-a489-070296ced968.asp

And documention for the File System Object classes here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/057b68c9-6172-4f02-a6f3-12d85d16ac6a.asp
0
 

Author Comment

by:asgarcymed
ID: 16469148
vinnyd79 - That's it, thank you a lot !
0
 

Author Comment

by:asgarcymed
ID: 16469157
Idle_Mind  - thank your for the advices and links !
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month20 days, 13 hours left to enroll

864 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