Skip to content

Commit

Permalink
feat: Prevent renaming of current directory in flat rename command
Browse files Browse the repository at this point in the history
  • Loading branch information
Laisky committed Dec 23, 2024
1 parent ceb53cd commit e6a1508
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ var renameFlatCmd = &cobra.Command{
return errors.Wrapf(err, "get relative path of %s", path)
}

if rel == "." {
return nil
}

prefix := strings.TrimSpace(strings.Split(rel, string(os.PathSeparator))[0])
newName := prefix + "_" + filepath.Base(path)
targetPath := filepath.Join(baseDir, newName)
Expand Down

0 comments on commit e6a1508

Please sign in to comment.