Last active
June 16, 2024 05:42
-
-
Save KyonLi/13519d7f9b06046723c2de3da88c5bfc to your computer and use it in GitHub Desktop.
Revisions
-
KyonLi revised this gist
Jun 16, 2024 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,13 +5,13 @@ prefix="*-" shopt -s nullglob rename(){ local files=( $prefix* ) for i in ${!files[*]} do local file=${files[i]} mv "$file" "${file#$prefix}" echo "$file → ${file#$prefix}" done } rename -
KyonLi revised this gist
Jun 16, 2024 . 1 changed file with 17 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ #!/bin/bash prefix="*-" shopt -s nullglob rename(){ local files=( $prefix* ) for i in ${!files[*]} do local file=${files[i]} mv "$file" "${file#$prefix}" echo "$file → ${file#$prefix}" done } rename -
KyonLi created this gist
Jan 30, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #!/bin/bash ext=jpg shopt -s nullglob OLDIFS=$IFS rename(){ IFS=$'\n' local arr=( $(ls -v *.$ext) ) IFS=$OLDIFS for i in ${!arr[*]} do local filename=$(printf "%03d" $(($i+1))) mv "${arr[i]}" "${filename}.${ext}" echo "${arr[i]} → ${filename}.${ext}" done } rename This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ #!/bin/bash vid_ext=mkv sub_ext=ass after_sub_ext=sc.ass shopt -s nullglob rename(){ local vid_arr=( *.$vid_ext ) local sub_arr=( *.$sub_ext ) for i in ${!vid_arr[*]} do local filename=${vid_arr[i]%.*} mv "${sub_arr[i]}" "${filename}.${after_sub_ext}" echo "${sub_arr[i]} → ${filename}.${after_sub_ext}" done } rename