Terminal error
I'm trying to move all mp3 I have to a single folder using the following
find / -iname "*.mp3" -type f | xargs -I '{}' mv {} /mnt/mp3 (posted here But I receive the following error: xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option It actually doesn't find any mp3 (which actually exists) Is there any error in the argument? Thanks for your help! |
null.
|
Quote:
Code:
find / -iname “*.mp3″ -type f -print0| xargs -0 -I ‘{}’ mv {} /mnt/mp3 |
Quote:
|
Sorry SAbhi. Your right. I edited my comment as 'Null.'.
|
One thing that can cause this is if a file name has an apostrophe in it. With the quotes around "*.mp3" (which is valid, as it prevents the shell from interpreting it at the wrong time). The expansion, however, with xargs WOULD generate an error.
Another thing that would cause problems is spaces in the file name... One thing you can try is to use a "set -vx" just before running the command. This turns on debugging in the shell and it will show everything that is done to the command line... |
Thanks for your comments
I putted some mp3 files in my desktop. Tried to move them to Music The results are these: kilee@lap:~$ find /home/ki/Desktop/ -iname "*.mp3" -type f | xargs -0 -I '{}' mv {} /home/luis/Music/ find /home/luis/Desktop/ -iname "*.mp3" -type f | xargs -0 -I '{}' mv {} /home/luis/Music/ + xargs -0 -I '{}' mv '{}' /home/luis/Music/ + find /home/luis/Desktop/ -iname '*.mp3' -type f mv: cannot stat ‘/home/luis/Desktop/01 - Locked Out Of Heaven.mp3\n/home/luis/Desktop/09 PSY - Gangnam Style.mp3\n/home/luis/Desktop/05 - One More Night.mp3\n’: No such file or directory Just in case it is important, I'm using a xubuntu 13.04 2gb ram. Thanks again for your help! |
Quote:
ok that happen when you dont see what actually is provided to you, please see my last post... i gave a whole command. run it as it is but change the dir location. Below again: Code:
find / -iname “*.mp3″ -type f -print0| xargs -0 -I ‘{}’ mv {} /mnt/mp3 |
for something like this, use find's exec
Code:
find / -iname "*.mp3" -type f -exec mv {} /mnt/mp3/ ';' if the dir "mp3" did not exist you would end up moving the first file to file "/mnt/mp3" then overwrite it with the next.... and so on for more complex 'operations' use while read. Code:
while read File;do |
Thanks a lot
This worked perfect: find / -iname "*.mp3" -type f -exec mv {} /mnt/mp3/ ';' |
Quote:
this curly braces {} and the ';' <-- what function does it perform? Thanks. :) |
did some Googling, just share it with anyone interested or who can simplified it or give further details:
This action works like this: -exec command {} ; where command is the name of a command, {} is a symbolic representation of the current pathname and the semicolon is a required delimiter indicating the end of the command. |
yeap ;)
Code:
man find , note .. you must escape the ; , either \; or with ';' I tend ti use ';' as on my keyboard ; and ' are next to each other ;) you can also have + on the end make a dir, ( easy to delete later ) cd into it Code:
touch foo{1,2,3} |
Thank you all.
This has helped me a lot! One aditional question. Is it possible to define a list of extensions extensions? let's say using this with the find command? --include-from=/Users/me/Desktop/list.txt --include=*/ --exclude=* Where List.txt includes all the possible extensions I need to move? THanks! |
Just to let you know, it doesnt work!
|
All times are GMT -5. The time now is 12:13 AM. |