Jump to content

Rename your files Vista's way


Ibrahim
 Share

Recommended Posts

what it does is to skip the file extension while you are renaming a file and skip select the name only

The issue I had is to make it unique for explorer and desktop but i couldn't.

For Desktop

Msgbox(0,"Program by ibrahim ghorabah","Enjoy")
opt("WinWaitDelay",0)
 $a=""
 while @error=0
 WinWaitActive("Program Manager", "FolderView")
 $a = ControlGetFocus("Program Manager", "FolderView")
 IF $A="Edit1" THEN 
 ControlSend("Program Manager", "FolderView","[CLASS:Edit; INSTANCE:1]", "{LEFT}{LEFT}{LEFT}{LEFT}{SHIFTDOWN}{CTRLDOWN}{HOME}{SHIFTUP}{CTRLUP}")
 while $A="Edit1"
     $a = ControlGetFocus("Program Manager", "FolderView")
     if $a<>"Edit1" then ExitLoop
 WEnd
 Else
     WinWaitActive("Program Manager", "FolderView")
 ENDIf
 
 WEnd

For Explorer

opt("WinWaitDelay",0)
 opt("Wintitlematchmode",4)
 $a=""
 
 while @error=0
 WinWaitActive("classname=CabinetWClass", "")
 $a = ControlGetFocus("classname=CabinetWClass", "")
 IF $A="Edit2" THEN 
 ControlSend("classname=CabinetWClass","","[CLASS:Edit; INSTANCE:2]", "{LEFT}{LEFT}{LEFT}{LEFT}{SHIFTDOWN}{CTRLDOWN}{HOME}{SHIFTUP}{CTRLUP}")
 while $A="Edit2"
     $a = ControlGetFocus("classname=CabinetWClass", "")
     if $a<>"Edit2" then ExitLoop
 WEnd
 
 Else
     WinWaitActive("classname=CabinetWClass", "")
 ENDIf
 
 WEnd

any modifications are welcome!!

Edited by Ibrahim
Link to comment
Share on other sites

so...what exactly is this supposed to do? lmao

Rename files? with or without extentions?

try this Rename.au3 i just whipped up. the code is sloppy but hey it work's !

rename any file in any location, using a simple Array and some StringSplit functions.

;Opens the FileOpendialog ..duh
$var = FileOpenDialog("Please Select a file",@WorkingDir,"All Files (*.*)",1 + 4)
        
If @error Then
    MsgBox(4096,"","No File(s) chosen")
Else
    
       ;Loads the Array $Arr with everything from the given string, with the exception of the "\"
       ;$Arr[0] = Array Size , in my test i had 6 when it was split at the "\"
       ;C:\Users\Jesse\Desktop\AutoIt_Junk\Rename.au3

       ;$Arr[0] = 6
       ;$Arr[1] = C:
       ;$Arr[2] = Users
       ;$Arr[3] = Jesse
       ;$Arr[4] = Desktop
       ;$Arr[5] = AutoIt_Junk
       ;$Arr[6] = Rename.au3

       ;Creates the Arrays
    $Arr = StringSplit($var,"\")
    
       ;Sets the Variable $total as the total amount of Items in the Array
    $total = $Arr[0];<-remember its 6 (in my test)

        ;this is to test the Array and see how many Items is in it etc..and if it's working properly.
    _arraydisplay($arr,"hmm")

       ;now we set variable $sp to an Array by simply splitting the Last known Item at the "." (which is our file name)
       ;$Arr[$total] <-- this is actually splitting $Arr[6] XD

    $sp = Stringsplit($Arr[$total],".")
        
    $f_name = $sp[1];<------this is the filename
    $ext = $sp[2];<----this is the Extention
    
       ;MsgBox to show the file and ext selected to see if it was correct.
        MsgBox(4096,"","You chose " & $f_name & " With an Extention of " & $ext)
    
       ;now in my au3 file this was setup differently, but you can alternately do it this way.

    $input = InputBox("File Rename","Please Rename your file, Including an extenstion is optional")
    
    If NOT StringInStr($input,".") then

            ;this here should make it so if you do NOT include an extention (EX: .au3)
            ;It should keep the original Extention and give it the name you chose.

        Filecopy($source & $Arr[$Arr[0]],$source & $input & "." & $ext)

    Else

        $spl = StringSplit($input,".")

    for $i = 1 to $Arr[0] - 1
        $source = $source & $Arr[$i] & "\"
    ;MsgBox(0,"hmm",$source)
    next
    MsgBox(0,"hmm",$source & $Arr[$Arr[0]] & @crlf & $source & $spl[1] & "." & $spl[2])
    Filecopy($source & $Arr[$Arr[0]],$source & $spl[1] & "." & $spl[2])
    EndIF
EndIF

Alot of MsgBox functions i know but its nice ot have it pop up and show exactly how it's working.

Rename.au3

Edited by blinko2008
Link to comment
Share on other sites

nice work but what's the source code man

http://www.autoitscript.com/forum/index.php?showtopic=65889

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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...