|
Answer» I am trying to write a batch file that will:
1. Select a DIRECTORY (EDI*.*) 2. Read the first line of each file (this line is the new filename I want) 3. Delete the first line. 4. Rename the file to the new file name.
Thanksif you have GAWK for WINDOWS (see my sig)
Code: [Select]BEGIN { for(i=1;i<ARGC;i++){ print "Processing file: "ARGV[i] getline newfile < ARGV[i] while( ( getline line < ARGV[i] ) >0 ){ print line > newfile } close(ARGV[i]) cmd = "ren "ARGV[i]" "newfile print cmd system(cmd) } } save the above as myscript.awk and on command line
Code: [Select]c:\edi> gawk -f myscript.awk *.* The rename works great. Thanks
Just need to know how I can delete the first line before the file gets renamed.
|