Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Renaming files after their directory name in multiple sub directories Post 302334529 by bakunin on Wednesday 15th of July 2009 08:07:15 PM
Old 07-15-2009
hmm, learning UNIX without reading the man pages is nigh impossible. Yes, they are tough to get used to, but i assure you that once you have acquired some UNIX skills and have grown used to using them you will ask why not everybody could have the help texts organized the same way. Believe me: try them for some time and you will grow to love them.

To your problem at hand: this is a typical problem for using the "find" command. "find" can be used to find files, as the name suggests, but in fact it is a sort-of command-line file manager, fully programmable and extensible.

Find a short explanation of how "find" works here: find command explained.

Since you said you want to learn I'll leave it at that for now. Try to create a solution based on that, try to understand the man pages of "find" and if you still have questions feel free to ask.

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Batch Renaming: Change files' extensions in many sub-directories

Hi all - I'm trying to rename a large number of files all at once and need some help figuring out the command line syntax to do it. I've already done quite a bit of research with the rename and mv commands, but so far haven't found a solution that seems to work for me. So: The files exist... (10 Replies)
Discussion started by: dave920
10 Replies

2. UNIX for Dummies Questions & Answers

renaming files in the directory

suppose i have a few file like "a b c.txt" , "hello world.c" etc...(files that have space between them in their filenames). how do i change their filenames to "a_b_c.txt" and "hello_world.c" respectively? heres what i have tried...but failed $ find -name "*" -exec mv "{}" "`echo {} | tr "... (4 Replies)
Discussion started by: c_d
4 Replies

3. UNIX for Dummies Questions & Answers

Moving files out of multiple directories and renaming them in numerical order

Hi, I have 500 directories each with multiple data files inside them. The names are sort of random. For example, one directory has files named e_1.dat, e_5.dat, e_8.dat, etc. I need to move the files to a single directory and rename them all in numerical order, from 1.dat to 1000(or some... (1 Reply)
Discussion started by: renthead720
1 Replies

4. Shell Programming and Scripting

Copy files from multiple directories into one directory without overwriting them

I have several directories and all those directories have .dat files in them. I want to copy all those .dat files to one directory say "collected_directory" The problem is I don't want to overwrite files. So, if two file names match, I don't want the old file to be overwritten with a new one. ... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

5. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

6. Shell Programming and Scripting

Renaming multiple files in a directory

Hello, I would like to rename all available files in a directory from Filename to Filename_Normal. I tried to use below script but it is giving some error: #!/bin/sh for i in `ls` do echo Changing $i mv $i $i_Normal done Error received: Usage: mv src target or: mv ... (10 Replies)
Discussion started by: manishdivs
10 Replies

7. Shell Programming and Scripting

Moving and renaming multiple files in a directory

Hi. I am trying to automate the movement and renaming of a number of files in a directory. I am using the 'mv' command as I do not have access to 'rename'. I have the following scripted FILES=$(ls /transfer/move/sys/mail/20130123/) if ; then for i in ${FILES} ; do mv... (4 Replies)
Discussion started by: jimbojames
4 Replies

8. Shell Programming and Scripting

Renaming files in multiple directories

Hi I have the following file structure and I want to rename all the abc.jar files to abc_backup.jar rock@server:~/rakesh> ls -R .: test1 test2 test3 ./test1: abc.jar ./test2: abc.jar ./test3: abc.jar (2 Replies)
Discussion started by: rakeshkumar
2 Replies

9. Shell Programming and Scripting

Rename files from multiple directories along with directory indicator

Hi, Friends, i have a requirement where i need to rename my files residing in multiple sub directories and move them to one different directory along with some kind of directory indicator. For eg: test--is my parent directory and it has many files such as a1.txt a2.txt a3.txt ... (5 Replies)
Discussion started by: gnnsprapa
5 Replies

10. UNIX for Beginners Questions & Answers

How to copy particular files from a multiple directories and paste in a new directory?

Dear all I have a multiple directories, say for example org1, org2, org3 ..... org100 and each directory having a file namely dnaG.fasta. I need to copy all the dnaG.fasta file from each directory and paste in another directory fastconcatg. Therefore, my script has to copy dnaG.fasta file from... (5 Replies)
Discussion started by: dineshkumarsrk
5 Replies
Graph::UnionFind(3pm)					User Contributed Perl Documentation				     Graph::UnionFind(3pm)

NAME
Graph::UnionFind - union-find data structures SYNOPSIS
use Graph::UnionFind; my $uf = Graph::UnionFind->new; # Add the vertices to the data structure. $uf->add($u); $uf->add($v); # Join the partitions of the vertices. $uf->union( $u, $v ); # Find the partitions the vertices belong to # in the union-find data structure. If they # are equal, they are in the same partition. # If the vertex has not been seen, # undef is returned. my $pu = $uf->find( $u ); my $pv = $uf->find( $v ); $uf->same($u, $v) # Equal to $pu eq $pv. # Has the union-find seen this vertex? $uf->has( $v ) DESCRIPTION
Union-find is a special data structure that can be used to track the partitioning of a set into subsets (a problem known also as disjoint sets). Graph::UnionFind() is used for Graph::connected_components(), Graph::connected_component(), and Graph::same_connected_components() if you specify a true "union_find" parameter when you create an undirected graph. Note that union-find is one way: you cannot (easily) 'ununion' vertices once you have 'unioned' them. This means that if you delete edges from a "union_find" graph, you will get wrong results from the Graph::connected_components(), Graph::connected_component(), and Graph::same_connected_components(). API add $uf->add($v) Add the vertex v to the union-find. union $uf->union($u, $v) Add the edge u-v to the union-find. Also implicitly adds the vertices. has $uf->has($v) Return true if the vertex v has been added to the union-find, false otherwise. find $uf->find($v) Return the union-find partition the vertex v belongs to, or "undef" if it has not been added. new $uf = Graph::UnionFind->new() The constructor. same $uf->same($u, $v) Return true of the vertices belong to the same union-find partition the vertex v belongs to, false otherwise. AUTHOR AND COPYRIGHT
Jarkko Hietaniemi jhi@iki.fi LICENSE
This module is licensed under the same terms as Perl itself. perl v5.10.0 2008-11-27 Graph::UnionFind(3pm)
All times are GMT -4. The time now is 07:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy