Sponsored Content
Top Forums Shell Programming and Scripting Having trouble with find rename jpg command Post 302880203 by RavinderSingh13 on Wednesday 18th of December 2013 04:23:01 AM
Old 12-18-2013
Hello,

Could you please try the following code.

Code:
a=`find . -name "*.jpg"`
set -A array $a
 
for i in ${array[@]}
do
file_name=`basename $i`
echo $file_name
new_name=`echo $file_name"_m"`
cp "$file_name" "$new_name"
done


Hope this may help you.

NOTE: kindly use cp -p to copy the files in same permissions.


Thanks,
R. Singh

Last edited by RavinderSingh13; 12-18-2013 at 05:35 AM.. Reason: mentioning the use for cp -p command
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

The trouble with FIND .......

Afternoon, I have a problem with the FIND and GREP commands working together. The command that I am typing is this:- find . -name *.sql -print --- This finds all files with an SQL suffix I then want to examine all those files to check for the existence of a string in them. I am... (2 Replies)
Discussion started by: chorse
2 Replies

2. Shell Programming and Scripting

Find and rename

Hi, I was wondering if there is a way to find a particular file and then give it as an input to a program and then dump it into another file. Something like this: find ./ -name '*.txt' -exec ~/processText {} > mod.<current_file> \; I've been trying all sorts of weird things but not... (2 Replies)
Discussion started by: Legend986
2 Replies

3. Shell Programming and Scripting

Simple BASH shell script to rename webcam jpg and copy into a new directory.

System: Ubuntu Intrepid Ibex I'm running webcamd as a sort of "security" program, but I need a script that will archive my webcam.jpg files. So, take the following file: /home/slag/www/webcam.jpg Rename it--preferably with a time stamp. Place it in say: /home/slag/www/history/ ... (4 Replies)
Discussion started by: robfindlay
4 Replies

4. Shell Programming and Scripting

find jpg's mkdir script help

I am having a problem getting this to work right. The script needs to search through directories and subdirectories. If a jpg is found then create a folder in that directory, so on and so forth. Here is what I have so far but it doesn't work right. Help please #!/bin/bash for d in `find ./... (1 Reply)
Discussion started by: jedhypes
1 Replies

5. Shell Programming and Scripting

Rename all ".JPG" files to ".jpg" under all subfolders...

Hi, Dear all: One question ! ^_^ I'm using bash under Ubuntu 9.10. My question is not to rename all ".JPG" files to ".jpg" in a single folder, but to rename all ".JPG" files to ".jpg" in all subfolders. To rename all ".JPG" to ".jpg" in a single folder, for x in *.JPG; do mv "$x"... (7 Replies)
Discussion started by: jiapei100
7 Replies

6. Shell Programming and Scripting

Find and Rename files using (find mv and sed)

In response to a closed thread for degraff63 at https://www.unix.com/shell-programming-scripting/108882-using-mv-find-exec.html the following command might do it as some shells spit it without the "exec bash -c " part: Find . -name "*.model" -exec bash -c "mv {} \`echo {} | sed -e 's//_/g'\`"... (0 Replies)
Discussion started by: rupert160
0 Replies

7. Shell Programming and Scripting

find and copy script trouble

Hi guys First thing to say is that I am entirely new to Shell Scripting and am trying to write a script to do something I thought would be relatively simple, but has escaped me. Essentially, I want to take file name information from a list, find the files listed and then copy the results into... (0 Replies)
Discussion started by: acheron
0 Replies

8. Shell Programming and Scripting

Find directories with same name and rename them

Hello Im trying to make a script in bash shell programming to find subdirectories with the same name into the same directory and rename one of them!! Could you please help me? Thanks in advance (1 Reply)
Discussion started by: BTKBaaMMM
1 Replies

9. Shell Programming and Scripting

Trying to find and rename files

but it's not working. Hello all. I'm running the following command to find files with a specific name and rename them, but the command prompt returns a short 10 seconds after executing and doesn't find or rename anything. What am I doing wrong here? find . -type f | for file in... (3 Replies)
Discussion started by: bbbngowc
3 Replies

10. UNIX for Beginners Questions & Answers

Linux find jpg and sort by date

I want to find all jpg files and then sort them by modification date. This is where I started. find . -type f -name "*.jpg" I tried to pipe a sort in there but that did not seem to work. Do I need to use xargs? (10 Replies)
Discussion started by: cokedude
10 Replies
MRENAME(1)						      General Commands Manual							MRENAME(1)

NAME
mrename - program to rename files SYNOPSIS
mrename 'pattern' prefix [option] DESCRIPTION
This manual page documents briefly the mrename command. This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. mrename is a tool for easy and automatic renaming of many files. The 'pattern' is the pattern to search files to rename (quoted to avoid that bash resolve it), and prefix is the prefix that will be added to the name of each file. The two alternative options for copying or moving files in the new name are explained below. All parameters are needed, and you have to stay and launch the script in the same direc- tory of the files to be renamed. The program should be able to write in this directory. OPTIONS
There are only the following three options. -c The option -c will copy each file with the new filename. -m The option -m will move each file in the new filename. -h Display help. EXAMPLE
If you have a directory with two jpeg images prof.jpg and forp.jpg and you want to add them a prefix like item0, item1 etc.. (that is item0prof.jpg, item1forp.jpg etc..) do this: cd /path/to/the/images mrename '*.jpg' item -c to copy each matching file into another with the new name mrename '*.jpg' item -m to rename each file without keeping a copy with the previous name Word-Wide-Web: http://alfalinux.sourceforge.net/mrename.php3 AUTHOR
: Giancarlo -rofus- Erra e-mail: rofus@mindless.com This manual page was written by Dr. Guenter Bechly <gbechly@debian.org>, for the Debian GNU/Linux system (but may be used by others). It is distributed under the GPL just like mrename itself. October 22, 2000 MRENAME(1)
All times are GMT -4. The time now is 10:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy