First line as file name?

General and specific configuration/INI settings

First line as file name?

Postby mooie » Fri Oct 13, 2006 4:18 pm

Hi....

If the first line of a text file is Growing Oranges is there a way for UltraEdit to automatically save it that way when saving the text file without having to type in the name when the Save dialog pops up?

:D
User avatar
mooie
Newbie
 
Posts: 2
Joined: Thu Oct 12, 2006 11:00 pm

Re: First line as file name?

Postby Bego » Fri Oct 13, 2006 5:17 pm

hi,

save where to ? always the same directory ? What about file-extension ?

Here is a simple macro-example to save your file to "c:\temp\growing orange" without extension:

Code: Select all
InsertMode
ColumnModeOff
HexOff
Top
Clipboard 9
Key HOME
StartSelect
Key END
Copy
SaveAs "c:\temp\^c"
ClearClipboard
Clipboard 0

hth, Bego

P.S.: see also there: Default file type or file extension for new files
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: First line as file name?

Postby Mofi » Fri Oct 13, 2006 5:20 pm

No!

And I really hate this MS Word mechanism because it produces many files with not really useful file names which make problems later, although the mechanism itself is not the problem. The real problem are the users who are too lazy to type in a decent file name (without spaces) because they are not forced to enter a decent file name.

Well, you can use an automatically loaded macro with an appropriate hotkey assignment to save new files with the first line as file name. An example macro code for this job:

IfNameIs ""
InsertMode
ColumnModeOff
HexOff
Top
Key END
IfColNumGt 1
".txt"
Clipboard 9
StartSelect
Key HOME
Copy
EndSelect
Key END
Key BACKSPACE
Key BACKSPACE
Key BACKSPACE
Key BACKSPACE
SaveAs "^c"
ClearClipboard
Clipboard 0
Else
SaveAs ""
EndIf
EndIf

It has some disadvantages:

The cursor is at end of the first line after execution. So you must use "Go to last position" to bring the cursor back to the position before save.

The file extension is fixed and you cannot modify the path. It will always save the file with the extension in the macro to current working directory whatever the current working directory is.

And it's not possible to change the line terminator or the file format before save as it is possible with the Save As command.

It's not possible to open the Save As dialog with the copied first line pasted into the File Name field.

Well, you can modify the macro above to copy the first line to windows clipboard (Clipboard 0) and just open the Save As dialog (SaveAs "") and you manually press Ctrl+V to insert the "file name".



Hi Bego!

I have seen your post after submitting my post. Your macro will not work for files where first line is an empty line.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4058
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: First line as file name?

Postby mooie » Fri Oct 13, 2006 5:25 pm

Save with a text extension, same directory every time.

:D

Thanks for the tips on macros!
User avatar
mooie
Newbie
 
Posts: 2
Joined: Thu Oct 12, 2006 11:00 pm

Re: First line as file name?

Postby Bego » Fri Oct 13, 2006 5:30 pm

Hi Mofi, auch noch wach oder was ?

Your macro will not work for files where first line is an empty line.

Right. But I don't think this is really important.

rds Bego
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany


Return to Configuration/INI Settings