Advertisement
Guest User

dedup_rename.sh

a guest
Jan 24th, 2021
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.45 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. topdir=$(realpath "$1")
  4. orig_path_dir="$topdir-orig_path"
  5. tmp_dedup_dir="$topdir-tmp_dedup"
  6.  
  7. mkdir "$orig_path_dir"
  8. mkdir "$tmp_dedup_dir"
  9.  
  10. cd $1
  11. cnt=0;
  12.  
  13. find . -type f | while read -r filename ;
  14. do
  15.     cnt=$(($cnt+1));
  16.     namefile="$cnt.${filename##*.}"
  17.     namefile_path="$orig_path_dir/$namefile"
  18.     dedup_file_path="$tmp_dedup_dir/$namefile"
  19.  
  20.     echo "$filename" > $namefile_path
  21.  
  22.     mv -v "$(cat $namefile_path)" "$dedup_file_path"
  23. done
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement