path_replace
Updated: June 28, 2019

A very fast routine that replaces sections of the fullpath filenames listed in a file.


% path_replace --help    

Usage: path_replace file1 /hetdata/data/ /home/sco/newdir/ file2  N 
arg1 - input list of fullpath FITS images 
arg2 - path to replace  
arg3 - path to insert   
arg4 - new file list name  
arg5 - run in verbose/debug mode (Y/N)  

 
This is actually a pretty useful tool, so I include the verbose example below.

Verbose Example of using path_replace:

Suppose I have a list of file names that use a fullpath. It is often the case that I might want to reset part of that full path. In particular, when I transfer files to a different machine, the fullpath names change slightly. Here is an example where this case is treated.


I had a list of files (in "acm_mcs_paths.out") that I processed on mcs: 
% cat acm_mcs_paths.out 
/hetdata/data/20180206/acm/20180206T032412.5_acm_sci.fits
/hetdata/data/20190204/acm/20190204T053337.2_acm_sci.fits
/hetdata/data/20190204/acm/20190204T062133.3_acm_sci.fits

I transferred these to my home computer's data disk. From the point of 
the date subdiretory name (e.g. "20180206") the file names are the same. 
What I need to have a file that works on my home machine is a ne file 
where I have replaced 
   /hetdata/data/
with 
   /media/sco/DataDisk1/sco/AD/HET_work/acm_raw_subsets/
   
Here is the command that does the job: 
% path_replace acm_mcs_paths.out /hetdata/data/ /media/sco/DataDisk1/sco/AD/HET_work/acm_raw_subsets/ file.2 N 

The new file I use on my home machine is: 
% cat file.2 
/media/sco/DataDisk1/sco/AD/HET_work/acm_raw_subsets/20180206/acm/20180206T032412.5_acm_sci.fits
/media/sco/DataDisk1/sco/AD/HET_work/acm_raw_subsets/20190204/acm/20190204T053337.2_acm_sci.fits
/media/sco/DataDisk1/sco/AD/HET_work/acm_raw_subsets/20190204/acm/20190204T062133.3_acm_sci.fits

 



Back to SCO CODES page