Gentoo Archives: gentoo-user

From: Joseph <syscon780@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] copy resize files with directories
Date: Fri, 21 Dec 2012 05:21:19
Message-Id: 20121221051947.GG22445@syscon7.inet
In Reply to: [gentoo-user] copy resize files with directories by Joseph
1 On 12/20/12 22:07, Joseph wrote:
2 >I've found this script that copy and resize file on the fly from one location to another.
3 >
4 >for INPUT in ./*.JPG; do OUTPUT=/media/stick/`echo $INPUT | sed 's/\.JPG/\_new\.JPG/'`; echo $INPUT /media/stick/$OUTPUT; convert $INPUT -scale 800x $OUTPUT; done
5 >
6 >I go into each directory manually and run this command, however my camera was originally
7 >set to start the same file name every time I empty it so I have the same file name in may directories (the are not unique) so every time I run this script it re-writes
8 >the original one.
9 >
10 >The ideal situation would be go into each directory and create the same director directory on the destination disk with modified files
11 >Can anybody suggest how can I rewrite this script to copy files together with directory or change the file to a unique one.
12 >
13 >I would like to span all directory I'm IN and bellow and run that script on any directory below.
14
15 I do I combine the script above with this one below:
16
17 find . -maxdepth 1 -type f -name "*rospslpar*" |while read filename; do
18 path_name=${filename%/*}
19 base_name=${filename##*/}
20 new_name="$(expr substr $base_name 14 6).jpg"
21 mv "$filename" "$path_name/$new_name"
22 done
23
24 It would help be rename the file with unique name.
25
26 --
27 Joseph