Jump to content
Sign in to follow this  
gregnottage

Help with searching through & renaming folders

Recommended Posts

gregnottage

Hi,

Please can someone tell me how to search through a given folder structure and rename subfolders found to A, B, C etc for each subfolder found? My folder structure contains extracted drivers and I need the structure to be renamed to look like this:

Audio

A

NIC

A

B

C

Video

A

B

etc.

Please can someone tell me how I can achieve this?

Many thanks,

Greg.

Share this post


Link to post
Share on other sites
gregnottage

Hi guys,

Please can someone give me some pointers on this?

I've tried looking at FileFindFirstFile and FileFindNextFile but I can't seem to get it to work with folder names?

Thanks,

Greg.

Share this post


Link to post
Share on other sites
gregnottage

Hi guys,

Please can someone give me some pointers on this?

I've tried looking at FileFindFirstFile and FileFindNextFile but I can't seem to get it to work with folder names?

Thanks,

Greg.

Share this post


Link to post
Share on other sites
MOCEwez

Hi guys,

Please can someone give me some pointers on this?

I've tried looking at FileFindFirstFile and FileFindNextFile but I can't seem to get it to work with folder names?

Thanks,

Greg.

If you are just wanting to create the structure then this should do it for you.

To rename the folders you'll have to use "DirCopy" and "DirRemove".

CODE
#Include <File.au3>

Dim $Root = "C:\"

Dim $Folders[3]

$Folders[0] = "Audio"

$Folders[1] = "NIC"

$Folders[2] = "Video"

Dim $SubFolders[3]

$SubFolders[0] = "A"

$SubFolders[1] = "B"

$SubFolders[2] = "C"

Dim $PathToFolder

Dim $PathToSubFolder

For $i = 0 TO UBound($Folders) - 1

$PathToFolder = $Root & $Folders[$i]

If Not FileExists($PathToFolder) Then

DirCreate($PathToFolder)

MsgBox(0,"Folder Created", $Folders[$i])

EndIf

For $j = 0 To UBound($SubFolders)- 1

$PathToSubFolder = $PathToFolder & "\" & $SubFolders[$j]

if not FileExists($PathToSubFolder) Then

DirCreate($PathToSubFolder)

MsgBox(0,"Folder Created", $SubFolders[$j])

EndIf

Next

Next


Do not today what you can get someone else to do tomorrow.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.