Once in a while, I want to rename the current file to a different
directory that sometimes does not yet exist. This macro will do that,
too.
Periodically, I just want to easily open the directory location of the
current file. This macro will do that, as well.
While waiting for inspiration and since this macro is already so often
used, I added the TSE NewFile() command to the menu for creating
<unnamed...> files to play with.
Just to make things more polished (or more dull, depending on your
perspective), the TSE ChangeCurrFilename() is also available.
And, when the moon rises full and I am feeling vulnerably lonely, I feel
the need to create some new phantom friends in the form of a new
directory tree. You know, something like,
"c:\youarenot\alone\thereis\a\ghost\behindyou\". This macro does that,
too.
:)
Seriously, this is just part of my Assigned Key Reduction Project
(pronounded "ackurrp"). Using only a few discrete macros like this, I
have been able to avoid the hundred or so keys that I can never
remember. I am sure everyone else has already done this...
Enjoy.
***/
// nsf.s - create a new blank file with the current file's name to be
renamed at prompt
string rev[40]="NsfRev1010"
<f3> execmacro(rev)
/***
Macro Title: Newfile Similar Filename
Author: Hayes Smith
Written/Compiled With TSEPRO GUI 4.4
Save/Compile Date-:> 2012 04 23 @ 7:33 am
Category: File Accessory
Function: To create a newfile blank file and name it to a
name similar to the current filename
{This Revision:}
1010- 20120423- added changecurrfilename()
1009- 20120418- safe save
1008- 20120417- curing mistakes
1007- 20120416- adding TSE NewFile() and open folder of current file
1006- 20110918- safe save
1005- 20110101- added renaming current unnamed file to newfile
1004- 20100918- problem with mkdir
1003- 20100909- added edit history
1002- 2009 05 24 @ 3:45 pm- safe save
1001- new macro
-----------------------------
***/
menu mNsfmenu()
title="NSF Menu (NsfRev1010)"
history
"NSF New File"
"NSF Rename Current File"
"Other Things",,divide
"NSF Open Directory of Current File"
"TSE NewFile <unnamed...>"
"TSE Rename File"
"NSF Create New Directory Tree"
end
proc main()
string fil[_maxpath_]=currfilename()
string gfn[_maxpath_]=""
string mkgfn[_maxpath_]=""
string cr[1]=chr(13)
integer i=0
integer k=0
if pos("<unnamed-",lower(fil))
fil="NewFile"
endif
fil=fil+rightstr(str(gettime()),4)
k=mnsfmenu()
case k
when 1 // nsf new file
newfile()
when 2 // nsf rename file
savefile()
when 3 // divide
when 4 // open folder of current file
editthisfile(splitpath(fil,_drive_|_path_))
goto ending
when 5 // TSE NewFile()
newfile()
goto ending
when 6 // tse rename file
changecurrfilename()
goto ending
when 7 // creat new directory tree
fil=splitpath(fil,_drive_|_path_)
if ask("Create New Directory,ESC=Quit",fil) and length(fil)
and (fileexists(fil) & _directory_)==0
for i=1 to numtokens(fil,"\")//-1
gfn=gettoken(fil,"\",i)+"\"
mkgfn=mkgfn+gfn
if (fileexists(mkgfn) & _directory_)==0
mkdir(mkgfn)
endif
endfor
sound(9000,50)
msgbox("New Directory Confirmation",
"New Directory:"+cr+cr+mkgfn+cr+cr+
"Successfully Created.",_ok_)
editthisfile(mkgfn)
goto ending
else
sound(30,30)
warn("Cancelled or Directory Already Exists")
goto ending
endif
otherwise
sound(30,30)
message("("+rev+") Cancelled.")
goto ending
endcase
updatedisplay()
if ask("New Filename and Path, ESC=Cancel",fil,_edit_history_)
and length(fil)
and fileexists(fil)==0
addhistorystr(fil,_edit_history_)
for i=1 to numtokens(fil,"\")-1
gfn=gettoken(fil,"\",i)+"\"
mkgfn=mkgfn+gfn
if (fileexists(mkgfn) & _directory_)==0
mkdir(mkgfn)
endif
endfor
changecurrfilename(fil)
sound(9000,90)
message(rev+" Finished.")
else
sound(50,50)
message("Cancelled of File Exists. Nothing Done.")
goto ending
endif
goto ending
ending:
sound(1000,30)
end