creating copies of files in the same directory
I want to create copies of files in the same directory. So something like:
image1027.jpg image1028.jpg image1029.jpg to: image1027.jpg image1027_a.jpg image1028.jpg image1028_a.jpg image1029.jpg image1029_a.jpg I think it can be done with regex but I don't have any experience with it. |
Quote:
# or if you want to copy all jpeg's, >for i in *.jpg; do b=$(basename $i .jpg); do cp -p $b.jpg $b_a.jpg; done # or >for i in *.jpg; do b=$(echo "$i" | sed -e 's|\.jpg||'); do cp -p $b.jpg $b_a.jpg; done # or, if file names may have weird characters in such as 'spaces', >\ls *.jpg | while read i; do b=$(echo "$i" | sed -e 's|\.jpg$||'); a="cp -p '$b.jpg' '${b}_a.jpg'"; echo "$a"; eval "$a"; done Have fun! |
The last line worked. Thank you, rlx.
|
All times are GMT -5. The time now is 02:38 AM. |