Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up naming conventions #107

Open
rburghol opened this issue Dec 4, 2024 · 0 comments
Open

Clean up naming conventions #107

rburghol opened this issue Dec 4, 2024 · 0 comments

Comments

@rburghol
Copy link
Contributor

rburghol commented Dec 4, 2024

Moving files from:

  • [scenario]/precip/[segment]-[scenario]-all.csv to [scenario]/precip/[segment]_precip.csv
  • Ex: nldas2/precip/N51105-nldas2-all.csv to nldas2/precip/N51105_precip.csv

Bash script to rename all files inside a given scenario directory (like /media/model/met/nldas2rst):

for j in precip temp et; do 
  for i in `ls $j/`; do 
    coverage=${i%%-*}
    mv $j/$i $j/${coverage}_${j}.csv
  done
done

Bash script to do so inside all scenario directories (like /media/model/met):

  • Note: I had to run this as me and sudo'd as Connor since renaming apparently is not something that NFS permissions allow on this shared drive. @COBrogan
  • Added 2 special cases to rename the "-weekly" and "-daily" csvs
b=/media/model/met
for d in `ls $b/`;do
  for j in precip temp et; do 
    for i in `ls $b/$d/$j/`; do 
      coverage=${i%%-*}
      if [[ "$coverage" == "$i" ]]; then
        continue
      fi
      if [[ $i == *"-daily"* ]]; then
        echo "mv $b/$d/$j/$i $b/$d/$j/${coverage}_${j}_daily.csv"
        mv $b/$d/$j/$i $b/$d/$j/${coverage}_${j}_daily.csv
      elif [[ $i == *"-weekly"* ]]; then
        echo "mv $b/$d/$j/$i $b/$d/$j/${coverage}_${j}_weekly.csv"
        mv $b/$d/$j/$i $b/$d/$j/${coverage}_${j}_weekly.csv
      else 
        echo "mv $b/$d/$j/$i $b/$d/$j/${coverage}_${j}.csv"
        mv $b/$d/$j/$i $b/$d/$j/${coverage}_${j}.csv
      fi
    done
  done
done

@rburghol rburghol changed the title Clean up naming onventions Clean up naming conventions Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant