Cleaning up file names with paste, mv and/or sed?
Been a while since I've been on here. So I have a poorly labeled file collection. A friend wanted to see what I had so i
Code:
:~/ ls ~/files/ > badfiles.txt Code:
badfiles.txt goodfiles.txt I tried this with unintended results Code:
while read -r a b; do ! [[ -e "$b" ]] && mv "$a" "$b"; done <<< "$(paste badfiles.txt goodfiles.txt)" Code:
paste badfiles.txt goodfiles.txt | while read n k; do mv -T $n* $k; done |
Try parameter substitution to get the extensions
Code:
paste badfiles.txt goodfiles.txt | while read n k ; do ext=${n##*.} ; mv $n $k.$ext ; done Code:
sed 's/ /\\ /g' goodfiles.txt |
Thank you for the reply! I knew I had the right utilities, just wasn't sure how to define the variables as needed.
Now do I need to escape anything else? Specifically, some names include ? & ( ) ' ; , - |
So escaping everything came up with some errors..
Code:
sed ' I was testing this with: Code:
$ paste ../newbadfiles.txt | while read n ; do touch $n ; done Code:
's/.*/"&"/' |
All times are GMT -5. The time now is 08:49 AM. |