Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude File Type From Rename Script

Tags:

file

bash

rename

I need to exclude a single file type from the script below. Can someone show me what to add and exclusion for files that have a .partial extension?

#!/bin/bash
cd /data/user1/upload
thetime=`date +%Y-%m-%d_%H:%M:%S` #
for i in *.*
do
        extn=${i##*.} # save the extension of the file
                mv "$i" "${i%.*}"$(date "+_%Y-%m-%d_%H:%M:%S.${extn}")
done
mv *.* /test/user1
like image 923
JT-66 Avatar asked Sep 17 '26 03:09

JT-66


1 Answers

If you enable shopt -s extglob first, you can get all non-.partial files with !(*.partial).

like image 76
melpomene Avatar answered Sep 19 '26 17:09

melpomene



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!