Replication is one of the popular tools to determine the availability degree of resources (e.g., data files) in data grids. Since data grids involve limited file storages and high computing costs, replication process is very essential in these networks. This paper proposes a dynamic replication mechanism in a data grid that uses a weighted priority-based replication scheme, called WPRS. It specifies a value for existing each in a local storage based on three parameters including price, number of access time, and present time. When a resource is not available for a desired job, it is hired from other sites in the network. The proposed mechanism removes the file having the least value to increase the free space of data storage. Simulation results show that the proposed replication mechanism surpasses some of the existing replication methods in terms of the number of successful jobs, number of non successful jobs, and buy price.