Macro to save new files?

Help with writing and playing macros

Macro to save new files?

Postby hveld » Wed Apr 26, 2006 7:29 pm

Is there a way to make a macro that will automatically save all the new files to a specified fixed location, like C:\tmp, without prompting for a name for each file?

When you create new files, UE names them Edit1, Edit2, .. etc.
I want the macro to automatically save all such files as C:\tmp\Edit1, C:\tmp\Edit2 etc. without asking for names. No extension is fine.

I need this because I very often need to compare pieces of data I get from the clipboard. To do this I create new files and paste inside. UE can not compare non-saved files, and manually saving each one is just too tedious so I want to somehow automate it.

Thanks.
User avatar
hveld
Basic User
Basic User
 
Posts: 42
Joined: Tue Nov 16, 2004 12:00 am

Re: Macro to save new files?

Postby Mofi » Thu Apr 27, 2006 10:07 am

That was not really difficult for me. Here is the "SaveAllNewFiles" macro. This macro needs the macro property Continue if a Find with Replace not found checked.

It does not modify named files except if a named file is the current file on start of the macro. But even if the first file is a named file, the content of the named file is not really modified.

If you want the new files also closed automatically by this macro, insert the command CloseFile after the 2 SaveAs commands.

InsertMode
ColumnModeOff
HexOff
Clipboard 9
"FIRST FILE OF SAVE ALL NEW FILES MACRO"
Loop 38
Key LEFT ARROW
EndLoop
Loop
NextWindow
Find MatchCase "FIRST FILE OF SAVE ALL NEW FILES MACRO"
IfNotFound
IfNameIs ""
Top
"C:\tmp\"
CopyFilePath
Paste
StartSelect
Key HOME
Cut
EndSelect
SaveAs "^c"
EndIf
Else
Delete
IfNameIs ""
Top
"C:\tmp\"
CopyFilePath
Paste
StartSelect
Key HOME
Cut
EndSelect
SaveAs "^c"
EndIf
ExitLoop
EndIf
EndLoop
ClearClipboard
Clipboard 0
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Macro to save new files?

Postby hveld » Thu Apr 27, 2006 9:26 pm

Thank you very much Mofi !!

Works fine.
I wish it was that difficult for me :)
User avatar
hveld
Basic User
Basic User
 
Posts: 42
Joined: Tue Nov 16, 2004 12:00 am

Re: Macro to save new files?

Postby phseet » Wed Aug 01, 2007 3:37 am

Hi Mofi,

Found your macro very useful. I have modified it a bit so that it will not modify the current file if the current file is already a saved file; it will search the for the first unnamed file (up to 50):

InsertMode
ColumnModeOff
HexOff
Loop 50
IfNameIs ""
ExitLoop
EndIf
NextWindow
EndLoop
IfNameIs ""
Clipboard 9
"FIRST FILE OF SAVE ALL NEW FILES MACRO"
Loop 38
Key LEFT ARROW
EndLoop
Loop
NextWindow
Find MatchCase "FIRST FILE OF SAVE ALL NEW FILES MACRO"
IfNotFound
IfNameIs ""
CopyFilePath
SaveAs "C:\Tmp\^c"
EndIf
Else
Delete
IfNameIs ""
CopyFilePath
SaveAs "C:\Tmp\^c"
EndIf
ExitLoop
EndIf
EndLoop
ClearClipboard
Clipboard 0
EndIf

I use it to save temp files for comparison as well. Did wish that UE had direct support for comparing unnamed temp files. I think it once did, when the UltraCompare product was 'not born yet' as a separate product... :) Oh well...
User avatar
phseet
Newbie
 
Posts: 1
Joined: Tue Jul 31, 2007 11:00 pm

Re: Macro to save new files?

Postby Mofi » Wed Aug 01, 2007 7:54 am

Very good modification. I have marked always the first file to avoid an endless loop if there is no unnamed file. You solved that problem better with searching maximal 50 times for first unnamed file and do nothing if no unnamed file is found in fifty trials. Thanks, for that very useful improvement.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Macros