nimbus Posted October 25, 2004 Report Share Posted October 25, 2004 I have 60.000 html files. I must delete first 5 lines and last 8 lines in each files and save them. I cant open them same time because of the number of the files. So I have to open, delete, save and close them one by one. My text(html) editor is a spesific program (textpad) and it supports "delete line" feature. its shortcut is ctr+E and "close file" shortcut is ctr+w. All files are in same directory and I can rename them consecutive with the other program.(so to rename with macroexpress is not important and I am not asking this). thanks for possible answers and sorry my english. best regards. Quote Link to comment Share on other sites More sharing options...
Lars_Sandberg Posted October 25, 2004 Report Share Posted October 25, 2004 Hi, if it can't be done with ME alone, you could use UltraEdit (superb editor): http://www.idmcomp.com/ In UE you could have an internal macro (UE have it's own macroes) doing the deletion job + save, when a specific file is open. Then let MacroExpress handle the file open and close. In ME use: Text File Begin Process, which takes an ascii file which could be created from the OS command prompt: dir /b *.htm* >filelist.txt This will collect the filenames into an ascii file. With dir /s /b you also get content from subdirs. regards Lars Quote Link to comment Share on other sites More sharing options...
floyd Posted November 1, 2004 Report Share Posted November 1, 2004 Welcome to the forum! If it is true that you need to delete the first 5 and last 8 lines of a file and these numbers are fixed and each line ends with a CR/LF and that you do not need to rename them (i.e. they are to be overwritten) ... then you can use Macro Express to easily perform this task. Here is a sample macro: // T92 = Ascii CRLF Variable Set %T92% to ASCII Char of 013 Variable Set %T1% to ASCII Char of 010 Replace "%T92%" with "%T92%%T1%" in %T92% // Process each file in the folder. T1 holds the file name Repeat with Folder // Count the number of lines in the current file. T2 holds the current line // N1 holds the total number of lines in the file Variable Set Integer %N1% to 0 Text File Begin Process: "%T1%" Variable Modify Integer: Inc (%N1%) Text File End Process // Append to a string each line in the current file beginning // with 6 and ending with 9 lines from the end of the file // N2 holds the number of lines to keep in T3 Variable Modify Integer: %N2% = %N1% - 13 Variable Set String %T3% "" Text File Begin Process: "%T1%" Variable Modify String: Append "%T2%%T92%" to %T3% Text File End Process // Now save the string. Overwrite the file. Variable Modify String: Save %T3% to Text File Repeat End Macro Return <REM2:T92 = Ascii CRLF><ASCIIC:92:1:013><ASCIIC:1:1:010><TMVAR2:21:92:00:000:000:%T92%%T92%%T1%><REM2:><REM2:Process each file in the folder. T1 holds the file name><REP3:07:000002:000001:0001:0:01:C:\Temp2><REM2:><REM2:Count the number of lines in the current file. T2 holds the current line><REM2:N1 holds the total number of lines in the file><IVAR2:01:01:0><BTFBEG:002:000001:000000:%T1%><NMVAR:08:01:0:0000001:0:0000000><BTFEND><REM2:><REM2:Append to a string each line in the current file beginning><REM2:with 6 and ending with 9 lines from the end of the file><REM2:N2 holds the number of lines to keep in T3><NMVAR:02:02:1:0000001:2:0000013><TVAR2:03:01:><REM2:><BTFBEG:002:000006:N00002:%T1%><TMVAR2:07:03:00:000:000:%T2%%T92%><BTFEND><REM2:><REM2:Now save the string. Overwrite the file.><TMVAR2:17:03:00:000:000:%T1%F><REM2:><ENDREP><MRETURN> I've also attached this example. Of course you will need to change folders and do testing before actually running the macro. SampleMacroToDeleteLines.zip Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.