Selective, recursive file diddling!


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Selective, recursive file diddling!
# 1  
Old 04-07-2005
Question Selective, recursive file diddling!

Hello,

I have been trying all sorts of combinations and been royally screwing up my filesystem in the process Smilie I have a bunch of .wav files in a hierarchical album/artist etc folder structure and each has a duplicate .w4a file next to it.

All I want to do is move all the .w4a files to somewhere else, complete with the hierarchical folder structure, whilst leaving the .wavs where they are. I figured the following would work at the top level of the folder structure:

mv -r *.w4a ~/blah/blah/newplace/

Obviously i need to spend less time outside and more on the command line because this doesn't work Smilie

Sing your praises, I would.

Many thanks,
L
# 2  
Old 04-07-2005
What I would do is copy the top level of the heirarchical file structure i.e.

Code:
cp -r /toplevel ~/blah/blah/newplace/

cd ~/blah/blah/newplace/

find . -type f -name "*.wav" -exec rm -f {} \;

Of course make sure you have enough room for the initial copy of all the .wav and .w4a files.

Maybe someone else has a cleaner solution?
# 3  
Old 04-07-2005
Thanks for the suggestion, but I don't have the luxury of all that space.

I am trying to move just the compressed files from a large capacity external firewire drive to a laptop Smilie
# 4  
Old 04-07-2005
He said MOVE not RE-move!!! hehe...

There is no -r (recursive) option for mv that I know of... must use cp.

# This will recursively copy all the *.w4a files and directories to the new targetdir. then you must remove them... Be sure to start at the root of the filesystem. You might have to create the targetdir...

cp -r *.w4a targetdir
# 5  
Old 04-07-2005
Thanks, but sadly, I've already tried this.

cp -r *.w4a ~/blah/blah/someplace/

comes back with this:

cp: *.m4a: No such file or directory

The above command will only move any .w4a files in the current directory, it does not go down recursively - Smilie
# 6  
Old 04-07-2005
Try the full path instead.

or if that fails.

try cp -r . ~/to/some/dir.

Here is a good link. http://www.brandonhutchinson.com/Copy_directories.html


try this...
# cd fromdir; tar cf - . | (cd todir; tar xfp ###I think you can change the dot to *.w4a

There was a command line that I remembered using cpio that I cant remember...
# 7  
Old 04-07-2005
Quote:
Originally Posted by Kelam_Magnus
Try the full path instead.


There was a command line that I remembered using cpio that I cant remember...
Kelam I think this is what you meant...
Code:
find . -depth  | cpio -pdmv /path/tobe/copied/to

but combining that with -name gives

Code:
find . -depth -name "*.w4a" | cpio -pdmv /path/tobe/copied/to

and that should do what the original post asked for.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Backup script with selective file types only

i am looking for a backup script to be run in ssh which can move all *.php files only to a archive Eg. a folder has 5 sub folders with different file types, which can be mix of PDF, jpeg, gif etc etc. but the archive generated should only include the *.php files without breaking the directory... (3 Replies)
Discussion started by: netatma
3 Replies

2. Shell Programming and Scripting

Recursive delete in a file using a set of values in other file

Hi, I have got a file with 6K records and I want to delete 500 records from this file which match the values present in another file. Format of the both the files is different. Example : File 1 record CCCCCC 11292562ABCDEF MBR/PSF6/108100502/BEN01XXX XXX Example : File 2 record... (1 Reply)
Discussion started by: Nikhath
1 Replies

3. Shell Programming and Scripting

How to output selective delimited data to a new file?

I have the following file which at times can be quite large so can be difficult to read, I need a script that just extracts particular delimited data and outputs to alternate file $cat fix1.log FIX4.4|0=12|55=LIT.L|48=123456|32=5|52=20111107-10:52:22.128|38=100|10=200| ... (6 Replies)
Discussion started by: Buddyluv
6 Replies

4. Shell Programming and Scripting

Recursive file processing from a path and printing output in a file

Hi All, The script below read the path and searches for the directories/subdirectories and for the files. If files are found in the sub directories then read the content of the all files and put the content in csv(comma delimted) format and the call the write to xml function to write the std... (1 Reply)
Discussion started by: Optimus81
1 Replies

5. Shell Programming and Scripting

Selective position file editing inside folder

I need to process 4 files having name pattern as followis:- 1) Each file starts with = ABCJmdmfbsjop letters + 7 Digit Number _mm-dd-yyyy-hh-mm-ss-3 Digit Number.data where ABCJmdmfbsjop :- is alphabet. Each file starts with this ABCJmdmfbsjop alphabet. 7 Digit Number :- Numeric 7 digits. __:-... (1 Reply)
Discussion started by: lancesunny
1 Replies

6. Shell Programming and Scripting

capturing selective data from a vcd file

Hi, This is a vcd file.A vcd file may have 'n' modules. 1) I need to capture the data in bold,i.e. the module names (shown in bold) 2) Also i need to capture the data inside each individual module,say for tst_bench_top ,i need to capture data from line 4 to line 20 ... I just want one... (2 Replies)
Discussion started by: veerabahu
2 Replies

7. UNIX for Dummies Questions & Answers

Selective case conversion of a file

Hi all, I have a requirement to convert a file from one format to another. Parent file: to i.e., 1.) all the lines which begin with "Sample:", should be converted in such a way that entire text after ":" gets converted into all-lower case. 2.) all the lines which begin with... (7 Replies)
Discussion started by: dipanchandra
7 Replies

8. Shell Programming and Scripting

Copy selective lines from text file

Hello, I have a text file which I need to check for presence of certain tags, and then copy a subsequent portion of text into another file. The tag matching canbe done with Grep but I do not know how to copy selective lines from one file to another. Is it possible do that? I checked up some... (8 Replies)
Discussion started by: ajayram
8 Replies

9. Shell Programming and Scripting

Extract selective block from XML file

Hi, There's an xml file produced from a front-end tool as shown below: <INPUT DATABASE ="ORACLE" DBNAME ="UNIX" NAME ="FACT_TABLE" OWNERNAME ="DIPS"> <INPUTFIELD DATATYPE ="double" DEFAULTVALUE ="" DESCRIPTION ="" NAME ="STORE_KEY" PICTURETEXT ="" PORTTYPE ="INPUT" PRECISION ="15" SCALE... (6 Replies)
Discussion started by: dips_ag
6 Replies

10. UNIX for Dummies Questions & Answers

To compare selective file in different folders

Hello, I am using dircmp -d <folde1> <Folder2> to compare the files from two different foldes, but this command compares for all the files. Is there any option to select only some files for comparision. For example in Folder1: file1.txt file2.txt file3.txt Folder2 file1.txt file2.txt... (0 Replies)
Discussion started by: gmahesh2k
0 Replies
Login or Register to Ask a Question