norjms Posted December 18, 2009 Share Posted December 18, 2009 Hello Everyone, I've been playing around with the idea of having a user be able to rename files in my script. I have just been stuck on how to accomplish some of the functions. I looked through the help and couldn't come up with what I needed, so I'm going to ask here. expandcollapse popupFunc RenameFiles ;Path to the config file $Configure = @ScriptDir & "Bin\Configure\Configure.ini" ;Setting the source directory $SourceDirectory = iniread($Configure,"Source","Key","") ;Setting the output directory $OutputDirectory = iniread($Configure,"Output","Key","") If $SourceDirectory <> "" and $OutputDirectory <> "" Then $ListofFiles = _FileListToArray($SourceDirectory,"*.*, 1) For $Count = 1 To $ListofFiles[0] ;Need a way to count how many chars are in a filename and assign a variable to it $NumberofChars = ;something $ListofFiles ;Getting the extension $StringExt = StringTrimLeft($ListofFiles[$Count],$NumberofChars) ;Removing the extension $StringFileName = StringTrimRight($ListofFiles[$Count],4) ;How do I get a popup for the user to input the new filename? MsgBox(0,"Rename the files","The name of the current file is " & $StringFileName) ;then put an empty inputbox for the new file name on the popup ;the vari for the name file name will be $StringNewFileName ;Renaming FileMove($SourceDirectory & "\" & $ListofFiles[$Count],$OutputDirectory & "\" & $StringNewFileName & $StringExt) Next EndIf EndFunc Not sure how to accomplish this thanks for your suggestions Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 18, 2009 Moderators Share Posted December 18, 2009 norjms,Use InputBox: $StringNewFileName = InputBox("Rename the files","The name of the current file is " & $StringFileName, "", "", 500, 150)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
norjms Posted December 18, 2009 Author Share Posted December 18, 2009 norjms, Use InputBox: $StringNewFileName = InputBox("Rename the files","The name of the current file is " & $StringFileName, "", "", 500, 150) M23 Will this make a new windows open from an existing app? I understand the point of an input box, but an input box would be static and not inline with the array I would think. If I launch the function from a button... where will the old file name be, so I can use it as an example to know what to name the new filename? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 18, 2009 Moderators Share Posted December 18, 2009 norjms,Will this make a new windows open from an existing app?Yes.an input box would be static and not inline with the arrayYou can create the InputBox where you want, so you just need to use WinGetPos to find where your GUI is and then use some simple arithmetic to put the InputBox where you want.If I launch the function from a button... where will the old file name beIf you are asking the user to rename a file, you must know what the file is to start with, no? Otherwise what are you putting in your FileMove function?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now