Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Comparing strings in folder names

Original Message
Name: Desktop2k
Date: August 31, 2007 at 19:37:13 Pacific
Subject: Comparing strings in folder names
OS: xp
CPU/Ram: 2 gb
Model/Manufacturer: Intel
Comment:
Hi

I receive a lot of files daily that I have to sort out and I'd like to create a vb script that could simplify my life.

What I want to do is compare some strings (the string is always at the same location in the folder name, starts at character 13 and finishes at character 17) and move the files of the similar folders to one new folder called the string.

Example of my actual situation;

C:\123456-8901-apple-123456
|__inventory.txt
|__stock.txt

C:\abcdef-hijk-apple-lmnopk
|__ backorder.txt
|__ itemsold.txt

C:\fedcba-kjih-orang-kponml
|__ demands.txt
|__ refused.txt

C:\12d3fh-12df-orang-233412
|__grosslost.txt
|__netlost.txt

And so on…

Now, the results after the script has run would end up like this;

C:\apple
|__inventory.txt
|__stock.txt
|__ backorder.txt
|__ itemsold.txt

C:\orang
|__ demands.txt
|__ refused.txt
|__grosslost.txt
|__netlost.txt

I know that I would have to do some compare in my script but I don't know how to start it.

Any help would be greatly appreciated.

Thanks


Report Offensive Message For Removal


Response Number 1
Name: ghostdog
Date: September 1, 2007 at 00:44:31 Pacific
Subject: Comparing strings in folder names
Reply: (edit)
you should spend some time reading about vbs before posting. nevertheless, here's something to guide you..its not complete, so you got to do the rest
[code]
Dim objFSO,myFolder,objFolder,myFile,Folder
Set objFSO = CreateObject("Scripting.FileSystemObject")
myFolder="c:\test1"
Set objFolder = objFSO.GetFolder(myFolder)
For Each Folder In objFolder.SubFolders
FolderName = Folder.Name
dirName = Mid(..........) 'get the string here
For Each myFile In objFSO.GetFolder(myFolder & "\" & FolderName).Files
If Not objFSO.FolderExists(myFolder & "\" & dirName) Then
objFSO.CreateFolder(myFolder & "\" & dirName)
End If
'Copy or Move to destination
Next
Next
[/code]

Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Comparing strings in folder names

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




CPU and Graphics Upgrade Questions

VIRUS ALERT in Taskbar, HELP!

DSHUB24 Connection Problems

need help with dsl and dial up

novel 3.12


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC