Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Amendment on PDF file name


  • Please log in to reply
No replies to this topic
MJ Khor
  • Members
  • 17 posts
  • Last active: Aug 25 2015 02:42 AM
  • Joined: 05 Feb 2013

Dear All,

 

I would like to seek for your help on how to amend file name at the end.

For example:

 -Current file name is abc.pdf

 -After run the tool, the tools able to let user to key in text.

 -After submit, user input will amend at the end of the file name.

 -Like user input is "def", then the output will be abc_def.pdf

 

Currently I only know how to create a tool that change the whole file name.

#NoEnv

F1::

Gui:
Gui, +Sysmenu +Caption
clipboard =  
Send ^c     ;copy file name
ClipWait    ; Wait for the clipboard to contain text.
filepath = %clipboard%
SplitPath, filepath, name1, dir, ext, name_no_ext, drive
run, %filepath%

Gui, Add, Text, x20 y30 w100 h20 , File Name:

Gui, Add, Edit, x80 y30 w100 h20 vfname , 

Gui, Add, Button, x30 y60 w70 h30 , Submit
Gui, Add, Button, x100 y60 w70 h30 , Cancel
; Generated using SmartGUI Creator 4.0
Gui, Show, x127 y87 h100 w200, New GUI Window
Gui, +AlwaysOnTop
Return

ButtonSubmit:
Gui, Submit
Gui, destroy
Path = %filepath%
SplitPath, Path, name, dir, ext, name_no_ext, drive
SetTitleMatchMode 2
SetTitleMatchMode RegEx
WinClose,%name%
WinWaitClose,%name%

if (fname = "")
    fname := "Null"


DestinationPath = %dir%\%fname%.pdf
FileMove, %Path%, %DestinationPath%
Return

quit:
ExitApp
return

ButtonCancel:
GuiClose:
GUI, destroy
Return

Please help me on the code to amend user input at the end of the file name with a underscore separator.

 

Thanks.