浏览代码

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

(Yeah, I know, weirdly specific and likely not very useful.)
Alois Mahdal 8 个月前
父节点
当前提交
2a8a12d42e
共有 1 个文件被更改,包括 15 次插入0 次删除
  1. 15
    0
      dotfiles/config/bashum/main.bashrc

+ 15
- 0
dotfiles/config/bashum/main.bashrc 查看文件

@@ -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