Find all images, append unique prefix to name and move to different directory
Hi,
I have a directory with Multiple subdirectories and 1000s of pictures (jpg) in each directory. The problem is that each directory has a 001.jpg in them. I want to append a unique name (the directory_name)would be fine. and then move them to one main backup directory once they have been renamed.
I used the find command below on a test dir but it blew away duplicate names.
Code:
find ./ -type f -exec mv {} . \;
---------- Post updated at 01:37 PM ---------- Previous update was at 12:38 PM ----------
found the solution...
[CODE]rename -v 's/(.*)\/(.*)/$1_$2/;' */*
renames all the files in each directory with the directoryname_filename then moves them to the parent folder.
Last edited by Franklin52; 03-12-2012 at 02:15 PM..
Reason: Please use code tags for data and code samples, thank you
Using a bash script, I need to find all files in a folder "except" the newest file. Then I need to insert the contents of one text file into all the files found. This text needs to be placed at the beginning of each file and needs a blank line between it and the current contents of the file. Then I... (5 Replies)
Hi,
I have a command "get_data" with some parameters in few *.text files of a directory. I want to first find those files that contain this command and then append the following parameter to the end of the command.
example of an entry in the file :-
get_data -x -m50 /etc/web/getid
this... (1 Reply)
Hello, I have a lot of mp3 in a various directory. My goal is a command that find all mp3 file and move the files and directory where is the mp3 file to a destination folder.
Is it possible?
Thanks in advance (7 Replies)
I have have 6 empty directory below. I would like write bash scipt if any files less "1000000000" bytes then move to "/export/home/mytmp/final" folder first and any files greater than "1000000000" bytes then move to final1, final2, final3, final4, final4, final5 and that depend see how many files,... (6 Replies)
Greetings. I know enough Unix to be dangerous (!) and know that there is a clever way to do the following and it will save me about a day of agony (this time) and I will use it forever after! (many days of agony saved in the future)!
Basically
I need to find any image files (JPGs, PSDs etc)... (5 Replies)
Ultimately, I'm looking to create a script that allows me to plug in a usb drive with lots of jpegs on it & copy them over to a folder on my hard drive. So in the process of copying I am looking to hash check them, record dupes to a file, copy only 1 of the identical files (if it doesn't exsist... (1 Reply)
I have this situation
/u03/app/banjobs> ls -ltr icg*
82 Jun 12 10:37 iicgorldi_2419186.log
56810484 Jun 17 10:35 icgorldi_2421592.xml
2859 Jun 17 10:35 icgorldi_2421592.lis
- 125 Jun 17 10:35 icgorldi_2421592.log
82 Jun 12 10:37 iicgorldi_2419187.log
... (8 Replies)
In the awk below I am trying to use the file1 as a match to file2. In file2 the contents of $5,&6,and $7 (always tab-delimited) and are copied to the output under the header Quality metrics. The below executes but the output is empty. I have added comments to help and show my thinking. Thank you... (0 Replies)
In the bash below in each .zip there is a folder to be extracted Variants that I am trying to make unique by adding the prefix, before the _ from the .zip. The script does execute, but the prefix is not added to the extracted folder. Rather the Variants folder is added to each file within it. Thank... (1 Reply)
I was using below script to grep one file. I need to append the output using prefix
Data of all-Vms-1.txt
server-1 frame-1 LUN001
server-2 frame-1 LUN002
Data of all-vm-unix.txt
server-1 24
server-2 50
Script used
while read -r g h ;
do
cat all-Vms-1.txt |grep... (5 Replies)
Discussion started by: ranjancom2000
5 Replies
LEARN ABOUT HPUX
mktemp
mktemp(1) General Commands Manual mktemp(1)NAME
mktemp - make a name for a temporary file
SYNOPSIS
directory_name] prefix]
DESCRIPTION
makes a name that is suitable for use as the pathname of a temporary file, and writes that name to the standard output. The name is chosen
such that it does not duplicate the name of an existing file. If the option is specified, a zero-length file is created with the generated
name.
The name generated by is the concatenation of a directory name, a slash the value of the environment variable truncated to - 6 characters,
and the process ID of the invoking process.
The directory name is chosen as follows:
1. If the option is specified, directory_name is used.
2. Otherwise, if the environment variable is set and a string that would yield a unique name can be obtained by using the value of
that variable as a directory name, this value is used.
3. Otherwise, if a string that would yield a unique name can be obtained using as the directory, is used.
4. Otherwise, (current directory) is used.
If the option is specified, prefix is used instead of the value of the environment variable for name generation.
RETURN VALUE
returns zero on successful completion and non-zero if syntax, file access, or file creation errors were encountered or a unique pathname
could not be generated.
SEE ALSO mktemp(3C), umask(1).
mktemp(1)