Jump to content

Proper case and Dirmove


 Share

Recommended Posts

I have allot of folder that i want to rename to proper case

c:\test should be c:\Test

c:\this is a test should be c:\This is a test

i was going to use _stringproper and then dirmove to rename the folders

but since there are soo many of them (hundreds) i dont want all the moving activity to take place if the folder is already the proper case

I was going to use StringisLower and just see if they were all lower case and then rename based on that condition, BUT StringisLower reports 0 if there are spaces in the string (i.e. c:\this is a test)

so it wont work.

any other ideas?

Link to comment
Share on other sites

  • Moderators

I assume you already have your recursive file search done, and you know how to get the string for your file name... this is just an example, but you can mod it to fit what you need, and only change the file name while the DirMove() is going on if it is not proper.

Dim $String[3]
$String[1] = 'C:\gbc'
$String[2] = 'C:\Gbc'

For $i = 1 To UBound($String) - 1
    Local $FindString = StringLeft(StringTrimLeft($String[$i], StringInStr($String[$i], '\')), 1)
    If Asc($FindString) >= Asc('a') And $FindString <= Asc('z') Then 
        MsgBox(0, 'Test', 'String ' & $i & ' name does not start with a proper A to Z')
    Else
        MsgBox(0, 'Test', 'String ' & $i & ' name does start with a proper A to Z')
    EndIf
Next

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I assume you already have your recursive file search done, and you know how to get the string for your file name... this is just an example, but you can mod it to fit what you need, and only change the file name while the DirMove() is going on if it is not proper.

Dim $String[3]
$String[1] = 'C:\gbc'
$String[2] = 'C:\Gbc'

For $i = 1 To UBound($String) - 1
    Local $FindString = StringLeft(StringTrimLeft($String[$i], StringInStr($String[$i], '\')), 1)
    If Asc($FindString) >= Asc('a') And $FindString <= Asc('z') Then 
        MsgBox(0, 'Test', 'String ' & $i & ' name does not start with a proper A to Z')
    Else
        MsgBox(0, 'Test', 'String ' & $i & ' name does start with a proper A to Z')
    EndIf
Next

I think i can make that work.

Thanks!!

Link to comment
Share on other sites

I assume you already have your recursive file search done, and you know how to get the string for your file name... this is just an example, but you can mod it to fit what you need, and only change the file name while the DirMove() is going on if it is not proper.

Dim $String[3]
$String[1] = 'C:\gbc'
$String[2] = 'C:\Gbc'

For $i = 1 To UBound($String) - 1
    Local $FindString = StringLeft(StringTrimLeft($String[$i], StringInStr($String[$i], '\')), 1)
    If Asc($FindString) >= Asc('a') And $FindString <= Asc('z') Then 
        MsgBox(0, 'Test', 'String ' & $i & ' name does not start with a proper A to Z')
    Else
        MsgBox(0, 'Test', 'String ' & $i & ' name does start with a proper A to Z')
    EndIf
Next
OR you could just do a single line check and replace...

If StringIsLower(StringLeft($dirname,1)) Then $dirname = StringUpper(StringLeft($dirname,1)) & StringRight($dirname,StringLen($dirname)-1)
Link to comment
Share on other sites

  • Moderators

OR you could just do a single line check and replace...

If StringIsLower(StringLeft($dirname,1)) Then $dirname = StringUpper(StringLeft($dirname,1)) & StringRight($dirname,StringLen($dirname)-1)
Dammit :lmao: ... I can't tell you how many times I forget that 'StringIsLower' is even there!!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...