Sign in to follow this  
Followers 0
MHz

Mass rename to uppercase

17 posts in this topic

#1 ·  Posted (edited)

I have been working on my first autoit gui script. Cannot wait for final release, I guess. Titled - Windows XP Unattended CD SlipStream Plus.

My project is near end, but testing in virtual pc, I get a error of usbehci.sys not found. I have had this problem before. I am using Dircopy to get the files from the cd. Converting all files in I386 directory to uppercase seems to solve it. But how do I do this with autoit? Using Filemove will not work with a cd to rename to uppercase? Anyone please help.

Here is the working version to see.

Edited by MHz

Share this post


Link to post
Share on other sites



You are wanting to rename all of the files to upper case once you copy them to the HDD? I am not quite sure I understand your question.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Yes, I am wanting to rename the files to uppercase, so windows setup will see all the files. Some kind of setup glitch about lowercase?

I could use cdimage to change the case but because a $oem$ folder will be used, I do not want the files within it, changed to uppercase. Just the I386 files.

So I am looking for a function etc, that could give me the ability to change the case of the filenames.

Hope, I am alittle more clear.

Share this post


Link to post
Share on other sites

http://stevemiller.net/apps/

Look at Win32 Console ToolBox 1.0

It includes a program called filecase that can recursively rename files/folders to uppercase.


Who else would I be?

Share this post


Link to post
Share on other sites

That will work this-is-me as I do not know of a current AutoIt function that anyone has written to do that.

Of course you could always write your own function MHz.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Thanks for the tip, This-is-me. I shall test some scenerio's with different casing.

Share this post


Link to post
Share on other sites

;CHECK HERE CHECK HERE!
$sFolder = ' ';Folder to rename all files inside.
;CHECK HERE CHECK HERE!

if StringLeft($sFolder,1) <> '\' then $sFolder=$sFolder & '\'

$aFiles = _FileSearch($sFolder,5)
For $c = 1 to $aFiles[0]
   RunWait(@comspec & ' /c ren "' & $aFiles[$c] & '" "' & StringUpper( StringTrimLeft($aFiles[$c],StringInStr($aFiles[$c],'\',0,-1))) & '"','',@SW_HIDE)
   
Next



Exit
Func _FileSearch($sIstr, $iSF)
  ; $iSF can sum up.
  ; $iSF = 4 means don't return also folders, only files.
  ; $iSF = 2 means stop at the first found.
  ; $iSF = 1 means looking in subfolders.
   
  ; An array is returned with the full path of all files found. The pos [0] keeps the number of elements.
   Local $sIstr, $iSF, $sCriteria, $sBuffer, $iH, $iH2, $sCS, $sCF, $sCF2, $sCP, $sFP, $sOutPut = '', $aNull[1]
   $sCP = StringLeft($sIstr, StringInStr($sIstr, '\', 0, -1))
   If $sCP = '' Then $sCP = @WorkingDir & '\'
   $sCriteria = StringTrimLeft($sIstr, StringInStr($sIstr, '\', 0, -1))
   If $sCriteria = '' Then $sCriteria = '*.*'
   
  ;To begin we seek in the starting path.
   $sCS = FileFindFirstFile($sCP & $sCriteria)
   While $sCS <> - 1
      $sCF = FileFindNextFile($sCS)
      If @error Then
         FileClose($sCS)
         ExitLoop
      EndIf
      If $sCF = '.' Or $sCF = '..' Then ContinueLoop
      If Not (BitAND($iSF, 4) And StringInStr(FileGetAttrib($sCP & $sCF), 'd')) Then
         $sOutPut = $sOutPut & $sCP & $sCF & @LF
         If BitAND($iSF, 2) Then ExitLoop
      EndIf
   Wend
   
  ;And after, if needed, in the rest of the folders.
   If (BitAND($iSF, 2) Or BitAND($iSF, 3) And $sOutPut = '') Or (BitAND($iSF, 1) And Not BitAND($iSF, 2)) Then
      $sBuffer = @CR & $sCP & '*' & @LF;The buffer is set for keeping the given path plus a *.
      Do 
         $sCS = StringTrimLeft(StringLeft($sBuffer, StringInStr($sBuffer, @LF, 0, 1) - 1), 1);current search.
         $sCP = StringLeft($sCS, StringInStr($sCS, '\', 0, -1));Current search path.
         $iH = FileFindFirstFile($sCS)
         While $iH <> - 1
            $sCF = FileFindNextFile($iH)
            If @error Then
               FileClose($iH)
               ExitLoop
            EndIf
            If $sCF = '.' Or $sCF = '..' Then ContinueLoop
            If StringInStr(FileGetAttrib($sCP & $sCF), 'd') Then
               $sBuffer = @CR & $sCP & $sCF & '\*' & @LF & $sBuffer;Every folder found is added in the begin of buffer
               $sFP = $sCP & $sCF & '\';                            for future search
               $iH2 = FileFindFirstFile($sFP & $sCriteria);         and checked with the criteria.
               While $iH2 <> - 1
                  $sCF2 = FileFindNextFile($iH2)
                  If @error Then
                     FileClose($iH2)
                     ExitLoop
                  EndIf
                  If $sCF2 = '.' Or $sCF2 = '..' Then ContinueLoop
                  If Not (BitAND($iSF, 4) And StringInStr(FileGetAttrib($sFP & $sCF2), 'd')) Then
                     $sOutPut = $sOutPut & $sFP & $sCF2 & @LF;Found items are put in the Output.
                     If BitAND($iSF, 2) Then
                        FileClose($iH2)
                        FileClose($iH)
                        ExitLoop 3
                     EndIf
                  EndIf
               Wend
            EndIf
         Wend
         $sBuffer = StringReplace($sBuffer, @CR & $sCS & @LF, '')
      Until $sBuffer = ''
   EndIf
   
   If $sOutPut = '' Then
      $aNull[0] = 0
      Return $aNull
   Else
      Return StringSplit(StringTrimRight($sOutPut, 1), @LF)
   EndIf
EndFunc  ;==>_FileSearch

Share this post


Link to post
Share on other sites

@ezzetabi

That does look interesting.

I will try it.

Thankyou very much. :)

Share this post


Link to post
Share on other sites

@ezzetabi

Just had to do alittle change to you brilliant script. It was taking 3-4 minutes to process 5711 files. I changed it so it would write to a bat file first, wkich reduced it down to 3-4 seconds. As changes are shown.

;CHECK HERE CHECK HERE!
$sFolder = '';Folder to rename all files inside.
;CHECK HERE CHECK HERE!

If StringLeft($sFolder, 1) <> '\' Then $sFolder = $sFolder & '\'
$aFiles = _FileSearch($sFolder, 4)
$hnd = FileOpen('Conversion.bat', 1)
For $c = 1 To $aFiles[0]
   FileWrite($hnd, 'ren "' & $aFiles[$c] & '" "' & StringUpper( StringTrimLeft($aFiles[$c], StringInStr($aFiles[$c], '\', 0, -1))) & '"' & @CRLF)
Next
FileClose($hnd)
RunWait('Conversion.bat', '')
FileDelete('Conversion.bat')

This great script that you provided, deserves scripts and scraps imsertion. :)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Of course starting a single Cmd session with all commands is much faster than one per one. I did not think that.

Maybe because I tested in much less files.

Glad you found a workaround!

Edit why did you changed _FileSearch($sFolder, 5) to _FileSearch($sFolder, 4)? No need for subdirs?

Edited by ezzetabi

Share this post


Link to post
Share on other sites

You have good vision. I guess that was from the sample that I tested with alterations. Glad you saw this, saves displaying bad info. But my script does have 5 instead of 4, as displayed.

$sFolder = $open & '\i386';Folder to rename all files inside.
      If StringLeft($sFolder, 1) <> '\' Then $sFolder = $sFolder & '\'
      $message = GUICtrlCreateLabel('Converting I386 files to Uppercase', 10, 405, 570, 20)
      $aFiles = _FileSearch($sFolder, 5)
      $hnd = FileOpen(@TempDir & '\WXPUCDP_Temp.bat', 1)
      For $c = 1 To $aFiles[0]
       FileWrite($hnd, 'ren "' & $aFiles[$c] & '" "' & StringUpper( StringTrimLeft($aFiles[$c], StringInStr($aFiles[$c], '\', 0, -1))) & '"' & @CRLF)
      Next
      FileClose($hnd)
      RunWait(@TempDir & '\WXPUCDP_Temp.bat', '', @SW_HIDE)
      FileDelete(@TempDir & '\WXPUCDP_Temp.bat')

It works great, thanks. ezzetabi. :)

Share this post


Link to post
Share on other sites

If Ren works for with dirnames you can even use _FileSearch($sFolder, 1)

I did not test.. :)

Share this post


Link to post
Share on other sites

Since in the past few days after I made the 1337 translator everyone is going StringReplace() crazy, you might as well just do a stringreplace function and save time. Just replace all available lowercase letters with a Capital letter.

$text = InputBox("Welcome", "Please enter what u wanna make capital.")

$change = StringReplace($text, "a", "A", 0, 1)

etc...

Share this post


Link to post
Share on other sites

$text = InputBox("Welcome", "Please enter what u wanna make capital.")

$change = StringReplace($text, "a", "A", 0, 1)

etc...

<{POST_SNAPBACK}>

:)

$text = StringUpper($text)

Share this post


Link to post
Share on other sites

:)

$text = StringUpper($text)

<{POST_SNAPBACK}>

That works too, I'm just suggesting the StringReplace() way as another option.

Share this post


Link to post
Share on other sites

$sBuffer = StringReplace($sBuffer, @CR & $sCS & @LF, '')

Thanks for the tip, ezzetabi already has Stringreplace in his function. And it does seem to work well. :)

Share this post


Link to post
Share on other sites

Just for the heck of it, I think that you should go to the Scrips n' Scraps forum and check out my 1337 translator =).

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  
Followers 0