Skip to content

Instantly share code, notes, and snippets.

@ceholden
Last active August 29, 2015 14:08
Show Gist options
  • Save ceholden/bbb0dbccc52189275740 to your computer and use it in GitHub Desktop.
Save ceholden/bbb0dbccc52189275740 to your computer and use it in GitHub Desktop.
Move stacked Landsat images into correct locations for Jake
# CD to wherever the data are located, but NOT in the Stacks directory
cd [data location]
# Don't move the first time around -- do a "dry run"
# Redefine "do_move" to 1 to actually move the files
do_move=0
# Loop over stacks within "Stacks" directory, moving them into their own folders
for stk in Stacks/*stack; do
# Find just the Landsat bit of the ID, not the ESPA or the "stack" part
# String split on "-" of the filename
id=$(basename $stk | awk -F '-' '{ print $1 }')
echo "Moving $stk --> $id"
if [ "$do_move" == "1" ]; then
# Make the directory
mkdir -p $id
# Now move the stacked image
mv $stk $id/
# And .hdr and .aux.xml
mv ${stk}* $id/
fi
done
rmdir Stacks/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment