Sign in to follow this  
Followers 0
norjms

Rename with user input?

4 posts in this topic

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.

Func 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

Share this post


Link to post
Share on other sites



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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

norjms,

Will this make a new windows open from an existing app?

Yes.

an input box would be static and not inline with the array

You 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 be

If 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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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