SaveAs "current directory"

Help with writing and playing macros

SaveAs "current directory"

Postby member12345 » Thu May 22, 2008 6:09 am

Hello.

I'd like to know if there's a way to use SaveAs macro command to save the file under the same directory the file has been opened. I was just typing SaveAs "myfilename.htm" and the file wasn't created... So I tried putting a full path with SaveAs "C:\dirA\dir0xxx\myfilename.htm" and that worked. But since I need to apply this macro on hundreds of files and the dir0xxx aren't , of course, the same for each files, I can't put the full path.

I need to put SaveAs @currentDir&"myfilename.htm" (pseudo code)
Is it possible with UltraEdit10.00c ?

If not, with a newer version of UE ?

thanks.
member12345
Newbie
 
Posts: 1
Joined: Thu May 22, 2008 6:03 am

Re: SaveAs "current directory"

Postby Mofi » Fri May 23, 2008 1:01 am

If configuration setting Use active file directory for file open dialog default is set, the macro command SaveAs "new name of file" without a path will save in the same directory as active file is. Without this setting you have to create the full file name you want, for example with following code:

Top
CopyFilePath
Paste
Find Up Select "\"
IfSel
"\"
EndIf
"new name of file"
SelectToTop
Cut
SaveAs "^c"

This macro moves the cursor to top of the active file. Next it copies the full file name of the active file into the active clipboard and pastes it into the file. The cursor is now at the end of the inserted file name. The next command searches upwards for the last backslash in the file path and at the same time selects all text from current cursor position to end of found string. So it selects the name of the active file with the last backslash in the path. This selection is replaced by only a backslash = name of file is deleted. Next the new name of the file is inserted. The last 3 commands select the new full file name, cut it into the active clipboard and saves the file with the new full file name in the active clipboard.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4054
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Macros