Jump to content

File Extension Switcher


Achilles
 Share

Recommended Posts

I got the idea to create this when I realized that most email sites (like hotmail or gmail) don't allow you to send .exe files. This is a nice easy way to change that: Just convert the file to a .txt file and send it. The receiver (will of course have this program too :) ) and they just convert the .txt file to a .exe file.

Note: You can do this yourself by opening a folder, going to Tools/Folder Options/View and unchecking "Hide extension for known file types".

#NoTrayIcon
#include <GUIConstants.au3>
#Include <GuiList.au3>
#include <File.au3>

Opt("GUIOnEventMode", 1)

GuiCreate('File Extention Switcher', 500, 235) 

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

GuiSetFont(11)

GuiCtrlCreateLabel('To add a file to be converted click "Browse" and selet a file or drag a file to the list shown below...', 10, 4, 350, 35)

GuiSetFont(9)

$browse = GuiCtrlCreateButton('Browse', 380, 8, 110, 25)  
    GuiCtrlSetOnEvent(-1, '_Browse')
    GuiCtrlSetState(-1, $GUI_FOCUS)

$lstItems = GuiCtrlCreateList('', 10, 40, 480, 120, -1, $WS_EX_ACCEPTFILES)
    GuiCtrlSetState(-1, $GUI_DROPACCEPTED)
    GuiSetOnEvent($GUI_EVENT_DROPPED, '_Drop')

GuiSetFont(10)

GuiCtrlCreateLabel('Please insert the new file extension you would like the above file to have:', 10, 168, 420, 20) 
$extension = GuiCtrlCreateInput('', 440, 166, 50, 22)

GuiSetFont(9)

GuICtrlCreateButton('Remove From List', 10, 195, 230, 30) 
    GuiCtrlSetOnEvent(-1, '_Remove')
GuICtrlCreateButton('Convert Files', 260, 195, 230, 30) 
    GuiCtrlSetOnEvent(-1, '_Convert')

GuiSetState() 

While 1 
    Sleep(200) 
Wend 

Func _Drop() 
    _GUICtrlListAddItem ($lstItems, @GUI_DragFile)
EndFunc

Func _Browse() 
    $newFile = FileOpenDialog('Select a File', @MyDocumentsDir, 'All (*.*)', 3)
    If $newFile <> '' Then 
        _GUICtrlListAddItem ($lstItems, $newFile)
    EndIf 
    GuiCtrlSetState($browse, $GUI_FOCUS)
EndFunc 

Func _Remove() 
    $index = _GUICtrlListSelectedIndex($lstItems)
    _GUICtrlListDeleteItem($lstItems, $index)
EndFunc

Func _Convert() 
    If GuiCtrlRead($extension) = '' then 
        Msgbox(0, 'Warning', 'Please insert an extension before continuing...') 
        Return 
    EndIf
        
    For $a = 0 to _GUICtrlListGetInfo($lstItems) - 1
            
        $splitItem = StringSplit(_GUICtrlListGetText($lstItems, $a), '\') 
        $dir = ''
        For $b = 1 to $splitItem[0] - 1 
            $dir &= $splitItem[$b] & '\'
        Next 
        
        $nameSplit = StringSplit($splitItem[$b], '.') 
        $fileName = ''
        For $b = 1 to $nameSplit[0] - 1
            $fileName &= $nameSplit[$b] & '.'
        Next
        
        $extensionSplit = StringSplit(GuiCtrlRead($extension), '.') 
        $extensionText = ''
        For $c = 1 to $extensionSplit[0]
            $extensionText &= $extensionSplit[$c]
        Next 
        
        $pass = FileCopy(_GUICtrlListGetText($lstItems, $a), $dir & $fileName & $extensionText)
        If $pass = 1 then
            Msgbox(0, 'Success!', 'A new file has been created.') 
        Else 
            Msgbox(0, 'Failure...', 'Changing the extension failed.') 
        EndIf
    Next
    
EndFunc

Func _Exit() 
    Exit 
EndFunc

As always, comments/bugs/suggestions appreciated!

Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Somewhat useful to me in some cases. I don't have extension name shown because some people that use my computer may mess stuff up, and after a while it gets annoying to change the names.

Simple and Cool.

Thanks for the input.

Link to comment
Share on other sites

Somewhat useful to me in some cases. I don't have extension name shown because some people that use my computer may mess stuff up, and after a while it gets annoying to change the names.

Simple and Cool.

Thanks for the input.

Thanks! I don't have extensions shown either... I just discovered lately that that is how I could send programs via email so I decided to try to make a program to do it. And I succeeded! :)

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Thanks! I don't have extensions shown either... I just discovered lately that that is how I could send programs via email so I decided to try to make a program to do it. And I succeeded! :)

It's cool Piano_Man! Gud job...it's make my work become easier...thankss! :D

Edited by slayerz

AUTOIT[sup] I'm lovin' it![/sup]

Link to comment
Share on other sites

nice

thank you and it's very usefull !!!!!!

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

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