Skip to content

Instantly share code, notes, and snippets.

@HNygard
Created June 6, 2010 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HNygard/427686 to your computer and use it in GitHub Desktop.
Save HNygard/427686 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Rename file to the name of parent folder
# Install nautilus-actions:
# http://ubuntuforums.org/showthread.php?t=91377
# Only support 3 character file extention
extention=${1:(-4):4}
#echo $extention
# Getting name of the parent folder
parentdirectoryname=`dirname "$1" | tr / \\\\n | tail -1`
#echo $parentdirectoryname
directory=`dirname "$1"`
newname="${directory}/${parentdirectoryname}${extention}"
# Moving file
mv "$1" "$newname"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment