Jump to content

File Renamer


nitekram
 Share

Recommended Posts

Nothing great, but found this to be an issue for my brother and another friend, so I though I would put something together that was quick and dirty.

Say you want to create a slide show, and you want to make sure that the pics come up in the right order, well here you go. Rather then renaming your files, this does it for you, so that the pics will come up in the order you create.

So just drag your first pic over, and continue until completed. Once the GUI is closed, go to the new directory in your script folder, of course you can change that for your folder name.

; drag and drop pic renamer

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

Global $aListFiles[1], $sListFiles
Global $sPreFixName = '', $sFileType = ''
Global $sNewFolderName = 'FILE_RENAMER'

$sPreFixName = InputBox('Create Prefix', 'What is the prefix that you want for each file')

$gui = GUICreate('File_Renamer', 200, 200, -1, -1, -1, $WS_EX_ACCEPTFILES)
$ed = GUICtrlCreateEdit('', 5, 5, 190, 190)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState()

While 1
    $gm = GUIGetMsg()
    Switch $gm
        Case $GUI_EVENT_DROPPED
            $sListFiles &= StringRight(@GUI_DragFile, stringlen(@GUI_DragFile) - StringInStr(@GUI_DragFile, '\', 0, -1)) ;
            For $x = 0 To UBound($aListFiles) - 1
                Local $sTempPath = @GUI_DragFile
                $sTempPath = StringReplace($sTempPath, @CRLF, '')
                ;MsgBox('','',$sTempPath & '***')
                If $aListFiles[$x] = '' Then
                _ArrayAdd($aListFiles, $sTempPath)
                EndIf
            Next
            ConsoleWrite(@GUI_DragFile & '   ' & StringInStr(@GUI_DragFile, '\', 0, -1) & @CRLF)
            GUICtrlSetData($ed, $sListFiles)
        Case $GUI_EVENT_CLOSE

            ExitLoop
    EndSwitch
WEnd
_ArrayDelete($aListFiles, 0)
;_ArrayDisplay($aListFiles)

;DirCreate(@ScriptDir & "\PIC_RENAMER")
For $x = 0 To UBound($aListFiles) -1
    $sFileType = StringRight($aListFiles[$x], 3)
    ;MsgBox('','extension',$sFileType)
    ConsoleWrite('>! WRITING...' & $aListFiles[$x] & ' -->> ' & @ScriptDir & "\" & $sNewFolderName & "\" & $sPreFixName & $x + 1 & '.' & $sFileType & @CRLF)
        FileCopy($aListFiles[$x], @ScriptDir & "\" & $sNewFolderName & "\" & $sPreFixName & $x + 1 & '.' & $sFileType, 9)
        If @error Then MsgBox('','ERROR','Could not copy file to directory.')
Next

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

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