Commando to find and move mp3 file and directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Commando to find and move mp3 file and directory
# 1  
Old 02-16-2012
Commando to find and move mp3 file and directory

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
# 2  
Old 02-16-2012
The below snippet will search for mp3s in /home/ and all sub-directories inside /home/ and move it to /home/user/mp3s/
Code:
for x in `find /home/ -name "*.mp3"`; do mv $x /home/user/mp3s/; done

# 3  
Old 02-16-2012
Hello, thanks for replay, but does the script move the directory where is the mp3 file to a new destination?

Thanks
# 4  
Old 02-16-2012
It'll move anything that has '.mp3' in its name.
# 5  
Old 02-16-2012
Code:
find ~ -name *.mp3 -exec mv {} /home/user/mp3Dir \;

Should move all the melodies to the mp3Dir directory . Smilie
# 6  
Old 02-17-2012
Smilie
Code:
find -name *.end |
awk 'BEGIN 
{ FS="/"; pwd=ENVIRON["PWD"]; pa=pwd; }
{z=0;for(i=2;i<=NF:i++){ z++; if(i<NF){printf "mkdir " $i "\n"; printf "cd " $i "\n"; pa=pa "/" $i }else{ printf "mv " pa "/" $i " " $i "\n"}} 
for(i=1;i<z;i++){printf "cd ..\n"} pa=pwd}'

for testing mode operations are just printed out...
# 7  
Old 02-17-2012
Quote:
Originally Posted by daWonderer
Smilie
Code:
find -name *.end |
awk 'BEGIN 
{ FS="/"; pwd=ENVIRON["PWD"]; pa=pwd; }
{z=0;for(i=2;i<=NF:i++){ z++; if(i<NF){printf "mkdir " $i "\n"; printf "cd " $i "\n"; pa=pa "/" $i }else{ printf "mv " pa "/" $i " " $i "\n"}} 
for(i=1;i<z;i++){printf "cd ..\n"} pa=pwd}'

for testing mode operations are just printed out...
Some errors noted upon casual inspection:

find is missing the path argument. The pattern argument to the -name primary must be protected from shell expansion.

Also, there's a colon where a semicolon should be in the for loop's expression list.

Not an error; just an observation:
mkdir -p can create all intermediate pathname components with a single invocation.

Regards,
Alister
This User Gave Thanks to alister For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

2. Shell Programming and Scripting

How I can find the last file created and move it to a directory?

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)
Discussion started by: Bernardo Jarami
8 Replies

3. Shell Programming and Scripting

Move file in to directory- script

Hi In directory /mnt/upload I have about 100 000 files (*.png) that have been created during the last six months. Now I need to move them to right folders. eg: file created on 2014-10-10 move to directory /mnt/upload/20141010 file created on 2014-11-11 move to directory /mnt/upload/20141111... (6 Replies)
Discussion started by: primo102
6 Replies

4. UNIX for Dummies Questions & Answers

Find a list of files in directory, move to new, allow duplicates

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)
Discussion started by: Clyde Lovett
5 Replies

5. Shell Programming and Scripting

Please help list/find files greater 1G move to different directory

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)
Discussion started by: dotran
6 Replies

6. UNIX for Dummies Questions & Answers

move a file content to another directory

my script is: /u/user/orginal/:#! /bin/ksh find . -name "aur_prog*" -exec grep -il "error" > test.out #awk command to destination directory exit test.out file contain: ./aur_prog1.log ./aur_prog2.log ... (5 Replies)
Discussion started by: roughwal
5 Replies

7. Shell Programming and Scripting

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... (1 Reply)
Discussion started by: kmaq7621
1 Replies

8. Shell Programming and Scripting

Move the latest or older File from one directory to another Directory

I Need help for one requirement, I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix. Example: Source Directory : \a destination Directory : \a\b File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt) File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Discussion started by: pp_ayyanar
1 Replies

9. Shell Programming and Scripting

Move a file from windows directory to unix directory

Move a file from windows directory to unix directory, is this possible? if it is, can someone help me on this? Thanks! God bless! (1 Reply)
Discussion started by: kingpeejay
1 Replies

10. Programming

to find header in Mp3 file and retrieve data

hi all, In an mp3 file , data is arranged in sequence of header and data ,how to retrieve data between two headers. Is the data between two headers fixed? because as per theory it says 1152 samples will be there , but dont knw how many bits one sample correspond to? it would help if any c... (2 Replies)
Discussion started by: shashi
2 Replies
Login or Register to Ask a Question