I want a script to delete NDF file from a file group completely without using "shrinkfile " command
A file can be removed from the database only if the file is empty. Without
SHRINKFILE, the implication is that the file must be the only file in a user-defined filegroup and you must first drop or move all the objects (or partitions) from the filegroup to a different file group. The empty file can then be dropped with
ALTER DATABASE...REMOVE FILE.
It seems your objective is to delete data older than 6 months. It would be easier to just delete/truncate the data and not bother with files/filegroups at all.