Skip to content

Instantly share code, notes, and snippets.

@mfurlend
Created December 7, 2015 16:29
Show Gist options
  • Save mfurlend/bcdc91eda82fc7f0e539 to your computer and use it in GitHub Desktop.
Save mfurlend/bcdc91eda82fc7f0e539 to your computer and use it in GitHub Desktop.
recursively rename base name of files to parent folder's name (bash)
#!/bin/bash
for dir in *; do
if test -d "$dir"; then
(
cd $dir
for file in *; do
newfile=$dir.${file#*.}
mv "$file" "$newfile"
done
)
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment