Reputation: 83
I have a file similar to:
ISA.00. <rest of line>
information lines
information lines
...
...
...
ISA.00. <rest of line>
information lines
information lines
...
...
ISA.00. <rest of line>
I am using:
awk "/ISA.00./{file=(FILENAME)(++i)}{print > file}" %LOCATION%\%CURRFILE%
To loop through a folder of files, splitting them into files containing one "ISA" data set only. I want to keep the original source file name and add 1 to the end like subfile1, subfile2, subfile3. I have accomplished both.
How would I define an output directory, where the "subfiles" would go, leaving the original source file in the original location, and only having the "subfiles" in the "subfile directory".
I have run into a variety of dead ends and am asking for help as a last resort.
Thank you in advance!
Upvotes: 4
Views: 627
Reputation: 33327
Add the directory name before the filename:
print > "subfiles/"file
If you are on windows, you should use the backslash \
to separate the directory, like this:
print > "subfiles\\"file
(The backslash should be escaped)
This assumes that the directory already exists. Also, use single quotes when with awk, like awk 'commands'
file
Upvotes: 1