Browse Source

Add prepend() to simplify mass-renaming files by prepending a string

(Yeah, I know, weirdly specific and likely not very useful.)
Alois Mahdal 1 month ago
parent
commit
2a8a12d42e
1 changed files with 15 additions and 0 deletions
  1. 15
    0
      dotfiles/config/bashum/main.bashrc

+ 15
- 0
dotfiles/config/bashum/main.bashrc View File

@@ -13,6 +13,21 @@ test -f /usr/share/git-core/contrib/completion/git-prompt.sh \
13 13
 ### SUBZ ###
14 14
 ### '''' ###
15 15
 
16
+prepend() {
17
+    #
18
+    # pre-pend $2 to filename $1
19
+    #
20
+    local path=$1
21
+    local prefix=$2
22
+    local dirpath
23
+    local filename
24
+    local abspath
25
+    abspath=$(readlink -f "$path")
26
+    dirpath=$(dirname "$abspath")
27
+    filename=$(basename "$abspath")
28
+    echo mv "$path" "$dirpath/$prefix-$filename"
29
+}
30
+
16 31
 smv() {
17 32
     #
18 33
     # scp but rm the source